Part Number Hot Search : 
3EVKI CD2025 2SD180 LH28F XR16C8 KIA2431 IRFP442R 2SC51
Product Description
Full Text Search
 

To Download UPD17016GF-XXX-3B9 Datasheet File

  If you can't view the Datasheet, Please click here to try to view without PDF Reader .  
 
 


  Datasheet File OCR Text:
  mos integrated circuit m pd17016, 17017 4-bit single-chip microcontrollers with digital tuning system hardware the information in this document is subject to change without notice. the m pd17016 and 17017 are 4-bit single-chip cmos microcontrollers equipped with hardware for digital tuning systems. the cpu employs the 17k architecture and can directly manipulate the data memory, execute various operations, and control the peripheral hardware with a single instruction. all the instructions are one-word 16-bit instructions. as the peripheral hardware, a prescaler that can operate at up to 150 mhz, pll frequency synthesizer, and frequency counter for digital tuning systems, as well as many i/o ports, an lcd controller/driver, a/d converter, and d/a converter (pwm output) are provided. therefore, a high-performance, state-of-the-art digital tuning system can be organized with a single chip. in addition to the m pd17016 and 17017, a one-time prom model for program evaluation, the m pd17p005, is also available. features ? 17k architecture: general-purpose register method ? program memory (rom) 8 kb (3836 16 bits) : m pd17016 16 kb (7932 16 bits) : m pd17017 ? general-purpose data memory (ram) 320 4 bits: m pd17016 432 4 bits: m pd17017 ? instruction execution time 4.44 m s (with 4.5-mhz crystal resonator) ? decimal operation ? table reference ? hardware for pll frequency synthesizer dual modulus prescaler (150 mhz max.), programmable divider, charge pump unless otherwise specified, the m pd17017 is explained as the representative model in this document. ? a wealth of peripheral hardware general-purpose i/o ports, lcd controller/driver, se- rial interface, a/d converter, d/a converter (pwm output), beep output, frequency counter ? interrupt external: 1 internal: 1 ? power-on reset, reset by ce pin, and power failure detection circuit ? power-saving cmos ? supply voltage: v dd = 5 v 10% document no. u10664ej2v0ds00 (2nd edition) date published september 1996 p printed in japan the mark shows major revised points. 1996 data sheet
m pd17016, 17017 2 ordering information part number package m pd17016gf- -3b9 80-pin plastic qfp (14 20 mm) m pd17017gf- -3b9 80-pin plastic qfp (14 20 mm) remark indicates a rom code number. functional outline of m pd17016 and 17017 item function program memory (rom) ? 8 kb (3836 16 bits) : m pd17016 ? 16 kb (7932 16 bits) : m pd17017 all internal rom areas can be referenced as a table. general-purpose data memory (ram) ? 320 4 bits : m pd17016 ? 432 4 bits : m pd17017 general register: 16 4 bits instruction execution time ? 4.44 m s (with 4.5-mhz crystal resonator) stack level ? 7 levels (stack can be manipulated) general-purpose port ? i/o port : 16 pins ? input port : 8 pins ? output port : 9 pins (+8: lcd segment pin) beep output ? 1 pin selectable frequency (200 hz, 1 khz, 3 khz) lcd controller/driver ? 30 segments, 2 commons 1/2 duty, 1/2 bias, frame frequency: 125 mhz, drive voltage: v dd , segment pins multiplexed with key source pins: 16 8 pins can be used as output port pins (4 pins can be set in output mode at one time) serial interface ? 1 channel 3-wire (serial i/o) d/a converter ? 8 bits 2 channels (pwm output, output voltage: 16 v max.) a/d converter ? 6 bits 6 channels (successive approximation by software) interrupt ? 2 sources (maskable interrupt) external : 1 source (int 0 pin) internal : 1 source (timer) timer ? 2 channels timer carry (1, 5, 100, 250 ms) timer interrupt (1, 5, 100, 250 ms) reset ? power-on reset (on power application) ? reset by ce pin (ce pin low level ? high level) ? power failure detection function
m pd17016, 17017 3 item function pll frequency division mode ? two types synthesizer direct division mode (vcol pin : 30 mhz max.) pulse swallow mode (vcol pin : 40 mhz max.) (vcoh pin : 150 mhz max.) reference ? 12 programmable frequencies frequency 1, 1.25, 2.5, 3, 5, 6.25, 9, 10, 12.5, 25, 50, 100 khz charge pump ? two independent error out outputs phase comparator ? unlock detection by program frequency counter ? frequency measurement p1d 3 /fmifc pin : 5 to 15 mhz p1d 2 /amifc pin : 0.1 to 1 mhz supply voltage v dd = 5 v 10% package 80-pin plastic qfp (14 20 mm)
m pd17016, 17017 4 pin configuration (top view) 80-pin plastic qfp (14 20 mm, 0.8 mm pitch) m pd17016gf- -3b9 m pd17017gf- -3b9 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 80 79 78 77 76 75 74 73 72 71 70 69 68 67 66 65 64 63 62 61 60 59 58 57 56 55 54 53 52 51 50 49 48 47 46 45 44 43 42 41 p0c 1 p0c 0 p0a 3 p0a 2 p0a 1 p0a 0 p0b 3 p0b 2 /sck p0b 1 /so p0b 0 /si ic 0 int 0 ce p1a 3 p1a 2 p1a 1 p1a 0 p1b 3 p1b 2 /pwm 1 p1b 1 /pwm 0 p1b 0 /beep p1c 3 p1c 2 p1c 1 lcd 10 /ks 10 lcd 11 /ks 11 lcd 12 /ks 12 lcd 13 /ks 13 lcd 14 /ks 14 lcd 15 /ks 15 lcd 16 lcd 17 lcd 18 lcd 19 lcd 20 lcd 21 lcd 22 /p0e 0 lcd 23 /p0e 1 lcd 24 /p0e 2 lcd 25 /p0e 3 lcd 26 /p0f 0 lcd 27 /p0f 1 lcd 28 /p0f 2 lcd 29 /p0f 3 com 0 com 1 p2a 0 v dd2 p0c 2 p0c 3 p0d 0 /adc 2 p0d 1 /adc 3 p0d 2 /adc 4 p0d 3 /adc 5 lcd 0 /ks 0 lcd 1 /ks 1 lcd 2 /ks 2 lcd 3 /ks 3 lcd 4 /ks 4 lcd 5 /ks 5 lcd 6 /ks 6 lcd 7 /ks 7 lcd 8 /ks 8 lcd 9 /ks 9 p1c 0 p1d 3 /fmifc p1d 2 /amifc p1d 1 /adc 1 p1d 0 /adc 0 v dd1 vcol vcoh gnd x out x in eo 0 eo 1 ic 1 ic 2 ic 3
m pd17016, 17017 5 pin name adc 0 -adc 5 : a/d converter input p0e 0 -p0e 3 : port 0e amifc : am intermediate frequency p0f 0 -p0f 3 : port 0f counter input p1a 0 -p1a 3 : port 1a beep : beep output p1b 0 -p1b 3 : port 1b ce : chip enable input p1c 0 -p1c 3 : port 1c com 0 , com 1 : lcd common signal output p1d 0 -p1d 3 : port 1d eo 0 , eo 1 : error out output p2a 0 : port 2a fmifc : fm intermediate frequency pwm 0 , pwm 1 : d/a converter output counter input sck : serial clock i/o gnd : ground si : serial data input ic 0 -ic 3 : internal connection so : serial data output int 0 : external interrupt input vcoh : local oscillation high input ks 0 -ks 15 : key source signal output vcol : local oscillation low input lcd 0 -lcd 29 : lcd segment signal output v dd1 , v dd2 : power supply p0a 0 -p0a 3 : port 0a x in , x out : crystal resonator connection p0b 0 -p0b 3 : port 0b p0c 0 -p0c 3 : port 0c p0d 0 -p0d 3 : port 0d
m pd17016, 17017 6 block diagram 4 4 p0a 0 -p0a 3 p0b 0 -p0b 3 4 p0c 0 -p0c 3 4 p0d 0 -p0d 3 4 p1a 0 -p1a 3 4 p1b 0 -p1b 3 4 p1c 0 -p1c 3 4 p1d 0 -p1d 3 4 p0e 0 -p0e 3 4 p0f 0 -p0f 3 p2a 0 port lcd controller /driver pll osc com 0 ,com 1 lcd 0 /ks 0 lcd 15 /ks 15 lcd 21 lcd 25 /p0e 3 lcd 29 /p0f 3 lcd 16 lcd 22 /p0e 0 lcd 26 /p0f 0 vcoh vcol eo 0 eo 1 x in x out cpu peripheral rf system reg. ram 320 4 bits ( pd17016) 432 4 bits ( pd17017) alu instruction decoder program counter stack 7 12 bits ( pd17016) 7 13 bits ( pd17017) frequency counter fmifc/p1d 3 amifc/p1d 2 d/a converter pwm 1 /p1b 2 pwm 0 /p1b 1 a/d converter adc 5 /p0d 3 adc 2 /p0d 0 adc 1 adc 0 serial interface sck/p0b 2 si/p0b 0 beep beep/p1b 0 so/p0b 1 interrupt control int 0 timer reset v dd1 ce v dd2 gnd m m m rom 3836 16 bits ( pd17016) 7932 16 bits ( pd17017) m m m
m pd17016, 17017 7 contents 1. pin functions ................................................................................................................ ............ 12 1.1 pin function list ........................................................................................................... ..... 12 1.2 notes on using general-purpose port ............................................................................ 17 1.3 equivalent circuits of pins ............................................................................................... 18 1.4 processing of unused pins .............................................................................................. 22 1.5 notes on using ce and int0 pins ................................................................................... 23 2. program memory (rom) ........................................................................................................ 2 4 2.1 outline of program memory ............................................................................................. 24 2.2 program memory .............................................................................................................. .. 25 2.3 program counter ............................................................................................................. ... 26 2.4 program flow ................................................................................................................ ..... 26 2.5 notes on using program memory ................................................................................... 28 3. address stack (ask) .......................................................................................................... .... 29 3.1 outline of address stack .................................................................................................. 29 3.2 address stack register (asr) ......................................................................................... 29 3.3 stack pointer (sp) .......................................................................................................... .... 31 3.4 operation of address stack ............................................................................................. 32 3.5 notes on using address stack ........................................................................................ 32 4. data memory (ram) ............................................................................................................ ...... 33 4.1 outline of data memory .................................................................................................... 33 4.2 configuration and function of data memory ................................................................. 34 4.3 addressing of data memory ............................................................................................. 36 4.4 notes on using data memory .......................................................................................... 37 5. system register (sysreg) ................................................................................................... 38 5.1 outline of system register .............................................................................................. 38 5.2 system register list ........................................................................................................ .. 39 5.3 address register (ar) ....................................................................................................... 40 5.4 window register (wr) ....................................................................................................... 4 2 5.5 bank register (bank) ....................................................................................................... 4 3 5.6 index register (ix) and data memory row address pointer (mp: memory pointer) ... 44 5.7 general register pointer (rp) .......................................................................................... 46 5.8 program status word (psword) .................................................................................... 48 5.9 notes on using system register ..................................................................................... 49 6. general register (gr) ........................................................................................................ .. 50 6.1 outline of general register .............................................................................................. 50 6.2 general register body ....................................................................................................... 50 6.3 address generation of general register by each instruction ...................................... 51 6.4 notes on using general register .................................................................................... 52
m pd17016, 17017 8 7. alu (arithmetic logic unit) block .......................................................................................... 53 7.1 outline of alu block ........................................................................................................ .53 7.2 configuration and function of each block ..................................................................... 54 7.3 alu processing instruction list ...................................................................................... 54 7.4 notes on using alu .......................................................................................................... .58 8. register file (rf) ........................................................................................................... .......... 59 8.1 outline of register file .................................................................................................... .. 59 8.2 configuration and function of register file .................................................................. 60 8.3 control registers ........................................................................................................... .... 61 8.4 notes on using register file ........................................................................................... 66 9. data buffer (dbf) ............................................................................................................ ........ 67 9.1 outline of data buffer ...................................................................................................... .. 67 9.2 data buffer ................................................................................................................. ......... 68 9.3 peripheral hardware and data buffer list ...................................................................... 69 9.4 notes on using data buffer .............................................................................................. 72 10. interrupt ................................................................................................................... ................ 73 10.1 outline of interrupt block ................................................................................................. 73 10.2 interrupt control block .................................................................................................... .. 74 10.3 interrupt stack register................................................................................................... .77 10.4 stack pointer, address stack register, and program counter ........................................ 79 10.5 interrupt enable flip-flop (inte) ..................................................................................... 79 10.6 acknowledging interrupts ................................................................................................ 80 10.7 operation after interrupt has been acknowledged ....................................................... 85 10.8 restoring from interrupt processing routine ................................................................ 85 10.9 external (int 0 pin) interrupt ............................................................................................. 86 10.10 internal interrupt ........................................................................................................ ........ 87 10.11 notes on using interrupt ................................................................................................ .. 88 11. timer function .............................................................................................................. ........... 89 11.1 configuration of timer ....................................................................................................... 89 11.2 functional outline of timer .............................................................................................. 90 11.3 timer carry .................................................................................................................... ..... 90 11.4 timer interrupt ................................................................................................................ .... 105 12. standby ..................................................................................................................... .................. 114 12.1 configuration of standby block ...................................................................................... 114 12.2 standby function ........................................................................................................... .... 115 12.3 selecting device operation mode with ce pin ............................................................... 115 12.4 halt function .............................................................................................................. ........ 117 12.5 clock stop function ........................................................................................................ .. 127 12.6 device operations in halt and clock stop status .......................................................... 130 12.7 current consumption in halt status and clock stop status ........................................ 131
m pd17016, 17017 9 13. reset ....................................................................................................................... ..................... 136 13.1 configuration of reset block ........................................................................................... 136 13.2 reset function ............................................................................................................. ...... 137 13.3 ce reset ................................................................................................................... .......... 138 13.4 power-on reset ............................................................................................................. .... 143 13.5 relation between ce reset and power-on reset .......................................................... 146 13.6 power failure detection ................................................................................................... 1 50 14. pll frequency synthesizer ............................................................................................... 158 14.1 configuration of pll frequency synthesizer ................................................................ 158 14.2 functional outline of pll frequency synthesizer ........................................................ 159 14.3 input select block and programmable divider ............................................................... 160 14.4 reference frequency generator ...................................................................................... 165 14.5 phase comparator ( f -det), charge pump, and unlock detection block .................... 167 14.6 pll disabled status ........................................................................................................ .. 171 14.7 using pll frequency synthesizer .................................................................................. 171 14.8 status on reset ............................................................................................................ ...... 175 15. general-purpose port ........................................................................................................ . 176 15.1 configuration and classification of general-purpose ports ......................................... 176 15.2 functional outline of general-purpose ports ................................................................ 178 15.3 general-purpose i/o ports (p0a, p0b, p0c, and p1a) ................................................... 183 15.4 general-purpose input ports (p0d and p1d) .................................................................. 191 15.5 general-purpose output ports (p1b, p1c, and p2a) ..................................................... 193 15.6 general-purpose output ports (p0e and p0f) ............................................................... 195 16. a/d converter (adc) ......................................................................................................... ...... 198 16.1 configuration of a/d converter ....................................................................................... 198 16.2 functional outline of a/d converter ............................................................................... 198 16.3 input select block ......................................................................................................... ..... 199 16.4 compare voltage generation block ................................................................................ 201 16.5 compare block .............................................................................................................. ..... 204 16.6 performances of a/d converter ....................................................................................... 205 16.7 using a/d converter ........................................................................................................ .. 206 16.8 notes on using a/d converter ......................................................................................... 211 16.9 status on reset ............................................................................................................ ...... 211 17. d/a converter (dac) ......................................................................................................... ...... 212 17.1 configuration of d/a converter ....................................................................................... 212 17.2 functional outline of d/a converter ............................................................................... 212 17.3 output select blocks ....................................................................................................... .. 213 17.4 duty setting blocks and clock generation block .......................................................... 214 17.5 status on reset ............................................................................................................ ...... 217 18. beep output ................................................................................................................. ............. 218 18.1 method of beep output .................................................................................................... 21 8 18.2 output waveform of beep ............................................................................................... 219 18.3 status on reset ............................................................................................................ ...... 219 18.4 notes on using beep function ....................................................................................... 220
m pd17016, 17017 10 19. serial interface ............................................................................................................ ......... 221 19.1 configuration of serial interface ...................................................................................... 222 19.2 functional outline of serial interface .............................................................................. 223 19.3 shift clock and serial data i/o pin control blocks ........................................................ 224 19.4 clock generation block .................................................................................................... 2 26 19.5 clock counter .............................................................................................................. ....... 228 19.6 presettable shift register (sio1sfr) .............................................................................. 229 19.7 wait block ................................................................................................................. .......... 232 19.8 using serial interface ..................................................................................................... ... 234 19.9 status of serial interface on reset .................................................................................. 240 20. frequency counter (fc) ...................................................................................................... . 241 20.1 configuration of frequency counter............................................................................... 241 20.2 functional outline of frequency counter ....................................................................... 241 20.3 input select block and gate time control block ........................................................... 243 20.4 start/stop control block and if counter ........................................................................ 246 20.5 using if counter function ............................................................................................... 253 20.6 status on reset ............................................................................................................ ...... 255 20.7 notes on using frequency counter ................................................................................ 256 21. lcd controller/driver ....................................................................................................... . 258 21.1 configuration of lcd controller/driver ........................................................................... 258 21.2 functional outline of lcd controller/driver ................................................................... 259 21.3 lcd segment register ...................................................................................................... 2 61 21.4 output timing control blocks and segment/port select block ................................... 266 21.5 using lcd controller/driver ............................................................................................ 272 21.6 status on reset ............................................................................................................ ...... 274 22. key source controller/decoder .................................................................................. 275 22.1 configuration of key source controller/decoder .......................................................... 275 22.2 functional outline of key source controller/decoder .................................................. 276 22.3 key source data setting block ........................................................................................ 277 22.4 output timing control blocks and segment/port select block ................................... 279 22.5 key input control block ................................................................................................... 2 83 22.6 using key source controller/decoder ............................................................................ 286 22.7 status on reset ............................................................................................................ ...... 294 23. instruction set ............................................................................................................. .......... 295 23.1 outline of instruction set ................................................................................................. 295 23.2 legend ..................................................................................................................... ........... 296 23.3 instruction set list ....................................................................................................... ...... 297 23.4 assembler (as17k) embedded macroinstruction .......................................................... 299 23.5 software macroinstructions ............................................................................................. 300 24. reserved symbol ............................................................................................................. ....... 302 24.1 data buffer (dbf) .......................................................................................................... ..... 302 24.2 system register (sysreg) .............................................................................................. 302 24.3 lcd segment register ...................................................................................................... 3 03 24.4 port register .............................................................................................................. ......... 303 24.5 register file (control register) ......................................................................................... 30 5 24.6 peripheral hardware register .......................................................................................... 306 24.7 others ..................................................................................................................... ............ 306
m pd17016, 17017 11 25. electrical specifications ................................................................................................. 30 7 26. package ..................................................................................................................... ................. 310 27. recommended soldering conditions ............................................................................ 312 appendix a. note on connecting crystal resonator .................................................. 313 appendix b. differences among m pd17016, 17017, 17003a, 17005, and 17010 ................ 314 appendix c. development tools ............................................................................................ 319
m pd17016, 17017 12 1. pin functions 1.1 pin function list pin no. symbol function output form on power-on reset 79 p0c 3 4-bit i/o port. cmos input 80 p0c 2 can be set in input or output mode in 4-bit units. push-pull 1 p0c 1 2 p0c 0 3 p0a 3 note 4-bit i/o port. n-ch input 4 p0a 2 note can be set in input or output mode in 1-bit units. open drain, 5 p0a 1 5 v 6 p0a 0 (p0a 3 , p0a 2 ) cmos push-pull (p0a 1 , p0a 0 ) 7 p0b 3 port 0b and serial interface i/o. cmos input 8 p0b 2 /sck ? p0b 3 -p0b 0 push-pull (p0b 3 -p0b 0 ) 9 p0b 1 /so ? 4-bit cmos i/o port p0b 3 , 10 p0b 0 /si ? can be set in input or output mode in 1-bit units p0b 2 /sck, ? sck, so, si p0b 1 /so ? sck : serial clock i/o p0b 0 ? so : serial data output ? si : serial data input 11 ic 0 internally connected. connect this pin to v dd or gnd C C via resistor. 12 int 0 edge-detectable vectored interrupt input (rising edge C input detection). this pin is a schmitt trigger input pin with hysteresis characteristics. do not apply a voltage higher than v dd to int 0 pin on power application; otherwise, normal operation will not be performed. note the p0a 3 and p0b 2 pins are n-ch open-drain output pins and must be connected to an external pull-up resistor.
m pd17016, 17017 13 pin no. symbol function output form on power-on reset 13 ce selects operation of m pd17017 and inputs reset signal. C input (1) device operation selection pll frequency synthesizer can operate when ce pin is high; it is automatically disabled (operation prohibited) while ce pin is low. (2) reset signal input when ce pin goes high, device is reset in synchronization with internal basic timer 0 carry ff (ce reset). this pin does not accept low or high level of less than 110 to 165 m s to prevent malfunctioning due to noise. input signal level of this pin can be detected by ce pin level judge register of register file (address 07h). contents of ce pin level judge register are not changed by low or high level of less than 110 to 165 m s. this pin is a schmitt trigger input pin with hysteresis characteristics. do not apply voltage higher than vdd to this pin on power application; otherwise, normal operation will not be performed. 14 p1a 3 4-bit cmos i/o port. cmos input | | can be set in input or output mode in 1-bit units. push-pull 17 p1a 0 18 p1b 3 note port 1b also serving as d/a converter and buzzer output pins. n-ch outpus 19 p1b 2 /pwm 1 note ? p1b 3 -p1b 0 open drain, undefined data 20 p1b 1 /pwm 0 note ? 4-bit output port 16 v (p1b 3 -p1-b 0 ) 21 p1b 0 /beep ? pwm 1 , pwm 0 p1b 3 , ? d/a converter output with 8-bit resolution p1b 2 /pwm 1 , ? beep p1b 1 /pwm 0 ? buzzer output cmos push-pull (p1b 0 /beep) 22 p1c 3 4-bit cmos output port. cmos outputs | | push-pull undefined data 25 p1c 0 note the p1b 3 , p1b 2 /pwm 1 , and p1b 1 /pwm 0 pins are n-ch open-drain output pins and must be connected to an external pull-up resistor.
m pd17016, 17017 14 pin no. symbol function output form on power-on reset 26 p1d 3 /fmifc port 1d, frequency counter input, and analog input to a/d C input 27 p1d 2 /amifc converter. (p1d 3 -p1d 0 ) 28 p1d 1 /adc 1 ? p1d 3 -p1d 0 29 p1d 0 /adc 0 ? 4-bit input port ? fmifc, amifc ? input to fm and am intermediate frequency counter measurable frequency input pin input frequency input amplitude (mhz) (v p-p ) p1d 3 /fmifc 5-15 0.3 10.5-10.9 0.06 p1d 2 /amifc 0.1-1 0.3 0.44-0.46 0.05 because these pins are input pins of ac amplifier, cut dc components of input signals by using capacitor. ? adc 1 , adc 0 ? analog input to a/d converter with 6-bit resolution. 30 v dd1 positive power supply pins. supply 5 v 10% to these pins C C when cpu and peripheral functions operate. data can be retained at 2.2 v when clock is stopped. when v dd rises, m pd17017 is reset by internal power-on reset circuit. do not apply voltage higher than v dd pins (v dd1 and v dd2 ) to all pins other than v dd pins. especially, exercise care in raising v dd and ce pins simultaneously because latch up may occur. apply same voltage to v dd1 and v dd2 pins. v dd2 supplies power to crystal oscillation circuit (x in and x out pins) and error out circuit (eo 0 and eo 1 pins), and v dd1 pin supplies power to other circuits. 41 v dd2
m pd17016, 17017 15 pin no. symbol function output form on power-on reset 31 vcol inputs local oscillation frequency to pll. two types of C input 32 vcoh division modes are available: direct division (mf mode) and pulse swallow (hf and vhf modes). division mode input pin input frequency input voltage (mhz) (v p-p ) direct division (mf) vcol 0.5-30 0.2 pulse swallow (hf) vcol 5-40 0.2 pulse swallow (vhf) vcoh 9-150 0.2 because these pins are input pins of ac amplifier, cut dc components of input signal by using capacitor. 33 gnd ground C C 34 x out note crystal resonator connecting pins. cmos C connect crystal resonator of 4.5 mhz to these pins. push-pull 35 x in note C 36 eo 0 output from charge pump of pll frequency synthesizer. cmos 3-state high impedance if value resulting from dividing local oscillation (vco) frequency input to vcol (pin 31) or vcoh (pin 32) pin is higher than reference frequency, eo 0 and eo 1 pins output high level; if it is lower, these pins output low level. if two frequencies coincide, these pins are floated. because eo 0 and eo 1 pins output same signals, both pins can be used. 38 ic 1 internally connected pin. connect this pin to v dd via C C resistor. 39 ic 2 internally connected pins. leave these pins unconnected. C C 40 ic 3 42 ic 2 1-bit cmos output port. cmos outputs push-pull undefined data. 43 com 1 output common signals of lcd controller/driver. cmos3 low-level output 44 com 0 these pins output low level on execution of power-on ternary output reset or clock stop instruction in display off mode. note refer to appendix a. notes on connecting crystal resonator . 37 eo 1
m pd17016, 17017 16 pin no. symbol function output form on power-on reset 45 lcd 29 /p0f 3 port 0f, port 0e, segment signal output pins of lcd cmos low-level output | controller/driver, and key source signal output pins of key push-pull (lcd 29 -lcd 0 ) 48 lcd 26 /p0f 0 matrix. 49 lcd 25 /p0e 3 ? p0f 3 -p0f 0 | | ? 4-bit cmos output port 52 lcd 22 /p0e 0 ? p0e 3 -p0e 0 53 lcd 21 ? 4-bit cmos output port | | ? lcd 29 -lcd 0 58 lcd 16 ? segment signal output of lcd controller/driver. 59 lcd 15 /ks 15 ? ks 15 -ks 0 | | ? key source signal output of key matrix. 74 lcd 0 /ks 0 75 p0d 3 /adc 5 port 0d, analog input to a/d converter, and key source C input with | | signal return input of lcd segment. pull-down resistor 78 p0d 0 /adc 2 ? p0d 3 -p0d 0 (p0d 3 -p0d 0 ) ? 4-bit input port ? internal pull-down resistor is always on. ? adc 5 -adc 2 ? analog input to a/d converter with 6-bit resolution. ? internal pull-down resistor is off. ? key source return input ? internal pull-down resistor is on only while key source is output (220 m s) if lcd segment pin is used as key source, and off while lcd segment signal is output.
m pd17016, 17017 17 1.2 notes on using general-purpose port 1.2.1 data bit of port register input data of ports 0a, 0b, 0c, 0d, 1a, 1b, 1c, 1d, and 2a are read, and output data is set to these ports via the respective port registers (p0a through p2a registers) on data memory. the p0a 3 pin of port 0a correspond to the most significant bit of port register p0a, and the p0a 0 pins correspond to the least significant bit. likewise, the pins of the other ports, ports 0b, 0c, 0d, 1a, 1b, 1c, 1d, and 2a, correspond to the bits of the respective port registers. the output data of ports 0e and 0f are set by the lcd segment register on data memory. 1.2.2 i/o ports (ports 0a, 0b, 0c, and 1a) (1) when each port is set in input mode the status of each port pin is used as the value of the corresponding port register when an instruction that reads the contents of each port register on data memory is executed (when the address of a port register is specified as m of an instruction such as skt m, #n4 and add r, m). when an instruction that writes data to each port register is executed (when a port register address is specified as r of an instruction such as mov m, #n4 and add r, m), the value of the corresponding port is written to the output data latch circuit. (2) when each port is set in output mode when an instruction that writes data to each port register is executed, the value of the data is written to the data latch circuit, and output from the corresponding port pins. when an instruction that reads the contents of each port register is executed, the contents of the output data latch are used as the value of the port register. when an instruction that reads the contents of the port register corresponding to the p0a 3 and p0a 2 pins is executed, the statuses of the pins, which may be different from the output data, are read as is. all these port pins are set in the input mode on power-on reset, ce reset, and execution of the clock stop instruction. because the contents of the output data latch circuit are undefined on power-on reset, undefined data may be output unless an instruction that writes data to the port register is executed before a port is set in the output mode. the contents of the output data latch circuit are not affected by ce reset or execution of the clock stop instruction. 1.2.3 output ports (ports 1b, 1c, 0f, 0e, and 2a) an output port writes the value of the corresponding port register to the output data latch circuit and outputs it from each port pin when an instruction that writes data to the port register is executed. when an instruction that reads the value of the port register is executed, the status of the output data latch circuit is used as the value of the port register. undefined data is output on power-on reset. the current output data is retained on ce reset and execution of the clock stop instruction. however, ports 0e and 0f automatically output low levels on power-on reset and execution of the clock stop instruction.
m pd17016, 17017 18 1.3 equivalent circuits of pins (1) p0a (p0a 1 , p0a 0 ) p0b (p0b 3 , p0b 2 /sck, p0b 1 /so, p0b 0 /si) p0c (p0c 3 , p0c 2 , p0c 1 , p0c 0 ) note p1a (p1a 3 , p1a 2 , p1a 1 , p1a 0 ) (i/o) note the reset signal is not supplied to p0c. (2) p0a (p0a 3 , p0a 2 ) (i/o) v dd v dd reset v dd
m pd17016, 17017 19 (3) p1b (p1b 0 /beep) p1c (p1c 3 , p1c 2 , p1c 1 , p1c 0 ) p2a (p2a 0 ) lcd 0 /ks 0 -lcd 29 /p0f 3 (output) (4) p1b (p1b 3 , p1b 2 /pwm 1 , p1b 1 /pwm 0 ) (output) (5) p0d (p0d 3 /adc 5 , p0d 2 /adc 4 , p0d 1 /adc 3 , p0d 0 /adc 2 ) (input) (6) p1d (p1d 1 /adc 1 , p1d 0 /adc 0 ) (input) v dd v dd high on resistance a/d converter v dd a/d converter
m pd17016, 17017 20 (7) p1d (p1d 3 /fmifc, p1d 2 /amifc) (input) (8) ce int 0 (schmitt trigger input) (9) x out (output), x in (input) v dd v dd v dd general-purpose high on resistance frequency counter v dd v dd v dd high on resistance internal clock high on resistance x in x out
m pd17016, 17017 21 (10) eo 1 eo 0 (output) (11) com 1 com 0 (output) (12) vcoh vcol (input) v dd v dd v dd high on resistance high on resistance v dd v dd high on resistance high on resistance
m pd17016, 17017 22 1.4 processing of unused pins it is recommended that unused pins be processed as follows: table 1-1. processing of unused pins pin name i/o mode recommended processing port pins p0a 0 -p0a 3 i/o note 1 set general-purpose input port mode by software, and p0b 0 /si connect each port pin to v dd or gnd via resistor note 2 . p0b 1 /so p0b 2 /sck p0b 3 p0c 0 -p0c 3 p0d 0 /adc 2 -p0d 3 /adc 5 input connect each port pin to gnd via resistor note 2 . p0e 0 /lcd 22 -p0e 3 /lcd 25 cmos push-pull output open p0f 0 /lcd 26 -p0f 3 /lcd 29 p1a 0 -p1a 3 i/o note 1 set general-purpose input port mode by software, and connect each port pin to v dd or gnd via resistor note 2 . p1b 0 /beep cmos push-pull output open p1b 1 /pwm 0 , p1b 2 /pwm 1 n-ch open drain output set low-level output by software and leave port pins open. p1b 3 p1c 0 -p1c 3 cmos push-pull output open p1d 0 /adc 0 , p1d 1 /adc 1 input connect each pin to v dd or gnd via resistor note 2 . p1d 2 /amifc note 3 set port mode and connect each pin to v dd or gnd via p1d 3 /fmifc note 3 resistor note 2 . p2a 0 cmos push-pull output open ce input connect to v dd via resistor note 2 . com 0 , com 1 output open eo 0 , eo 1 output open ic 0 C connect to v dd or gnd via resistor note 2 . ic 1 C connect to v dd via resistor note 2 . ic 2 , ic 3 C open int 0 input connect to v dd or gnd via resistor note 2 . lcd 0 /ks 0 -lcd 15 /ks 15 output open lcd 16 -lcd 21 vcoh, vcol input disable pll by software and leave pins open. notes 1. the i/o port pins are set in the input mode on power application, execution of the clock stop instruction, or ce reset. 2. if a port pin is externally pulled up (connect to v dd via resistor) or down (connect to gnd via resistor) with a high resistance, the pin almost goes into a high-impedance state, and the current consumption (inrush current) of the port pin increases. generally, the pull-up and pull-down resistances are several 10 k w , although they vary depending on the application circuit. 3. do not set these pins as amifc and fmifc modes; otherwise, the current consumption will increase. pins other than port pins
m pd17016, 17017 23 1.5 notes on using ce and int 0 pins the ce and int 0 pins have a function to set a test mode (for ic test) in which the internal operations of the m pd17017 are tested, in addition to the functions listed in 1.1 pin function list . if a voltage higher than v dd is applied to either of these pins, the test mode is set. therefore, if noise exceeding v dd is applied to these pins even during normal operation, the test mode is set by mistake, affecting the normal operation. noise may be superimposed on these pins if the length of the wiring of these pins is too long. therefore, keep the wiring length as short as possible. if noise is inevitable, take noise suppression measures by using an external component as illustrated below. ? connect diode with low v f ? connect capacitor between ce or int 0 and v dd between ce or int 0 and v dd v dd ce, int 0 v dd diode with low v f v dd ce, int 0 v dd
m pd17016, 17017 24 2. program memory (rom) 2.1 outline of program memory figure 2-1 outlines the program memory. as shown in this figure, the program memory consists of a program memory and a program counter. the addresses of the program memory are specified by the program counter. the program memory has the following two major functions. (1) stores programs. (2) stores constant data figure 2-1. outline of program memory instruction constant data program memory program counter adddress specification
m pd17016, 17017 25 2.2 program memory figure 2-2 shows the configuration of the program memory. as shown in this figure, the program memory is configured as follows: m pd17016: 3836 16 bits (0000h through 0efbh) m pd17017: 7932 16 bits (0000h through 1efbh) all instructions are 1-word instructions 16 bits long, so that one instruction can be stored in one address of the program memory. constant data reads the contents of the program memory to the data buffer by using a table reference instruction. figure 2-2. configuration of program memory note valid in the address 0000h through 0efbh. reset start address timer interrupt vector int 0 pin interrupt vector (with pd17016) (with pd17017) m 16 bits page 0 call addr instruction subroutine entry address page 1 page 2 page 3 br addr instruction branch address br @ar instruction branch address call @ar instruction subroutine entry address movt dbf, @ar instruction table reference address address m 0000h 0001h 0002h 0003h 0004h 0005h 07ffh 0efbh 0fffh 17ffh 1efbh 00ffh br addr instruction branch address note br @ar instruction branch address call @ar instruction subroutine entry address movt dbf, @ar instruction table reference address (with pd17016) m (with pd17017) m
m pd17016, 17017 26 2.3 program counter figure 2-3 shows the configuration of the program counter. the program counter specifies an address of the program memory. bit pc 11 of the m pd17016, and pc 11 and pc 12 of the m pd17017 indicate a page. figure 2-3. configuration of program counter pc 12 pc 11 pc 10 pc 9 pc 8 pc 7 pc 6 pc 5 pc 4 pc 3 pc 2 pc 1 pc 0 page pc ( pd17017) pc ( pd17016) page m m 2.4 program flow the execution flow of the program is controlled by the program counter which specifies an address of the program memory. figure 2-4 shows the value set to the program counter when each instruction is executed. table 2-1 shows a vector address when an interrupt is acknowledged.
m pd17016, 17017 27 figure 2-4. specification of program counter on execution of each instruction (a) m pd17016 (b) m pd17017 program counter instruction br addr call addr br @ar call @ar movt dbf, @ar ret retsk reti when interrupt is acknowledged power-on reset, ce reset page 0 page 1 page 2 page 3 contents of program counter (pc) b 11 0 1 0 1 0 b 10 b 9 b 8 b 7 b 6 b 5 b 4 b 3 b 2 b 1 b 0 instruction operand (addr) instruction operand (addr) adddress register contents (return address) contents of address stack register (asr) specified by stack pointer (sp) vector address of each interrupt 000000000000 b 12 0 0 1 1 0 0 program counter instruction br addr call addr br @ar call @ar movt dbf, @ar ret retsk reti when interrupt is acknowledged power-on reset, ce reset page 0 page 1 contents of program counter (pc) b 11 0 1 0 0 b 10 0 b 9 0 b 8 0 b 7 b 6 b 5 b 4 b 3 b 2 b 1 b 0 instruction operand (addr) instruction operand (addr) adddress register contents (return address) contents of address stack register (asr) specified by stack pointer (sp) vector address of each interrupt 000000000000
m pd17016, 17017 28 table 2-1. interrupt vector address priority internal/external interrupt source vector address 1 internal int 0 pin 0005h 2 external timer 0003h 2.5 notes on using program memory the program memory of the m pd17016 does not have addresses 0efch through 0fffh, and that of the m pd17017 does not have addresses 1efch through 1fffh. therefore, do not use an instruction that causes the value of the program counter to be set to these addresses.
m pd17016, 17017 29 3. address stack (ask) 3.1 outline of address stack figure 3-1 outlines the address stack. the address stack consists of a stack pointer and address stack registers. the addresses of the address stack registers are specified by the stack pointer. the address stack saves a return address when a subroutine call instruction is executed or when an interrupt is acknowledged. the address stack is also used when a table reference instruction is executed. figure 3-1. outline of address stack stack pointer return address address stack register address specification 3.2 address stack register (asr) figure 3-2 shows the configuration of the address stack registers. there are eight 16-bit address stack registers: asr0 through asr7. actually, however, no register is assigned to asr7, and seven registers, asr0 through asr6, are used. the high-order 4 bits of asr0 through asr6 of the m pd17016 are fixed to 0, and the high-order 3 bits of the address stack registers of the m pd17017 are fixed to 0. the address stack saves a return address when a subroutine call instruction or table reference instruction is executed, or when an interrupt is acknowledged.
m pd17016, 17017 30 figure 3-2. configuration of address stack registers (a) m pd17016 stack pointer (sp) bit b 3 0 b 2 sp2 b 1 sp1 b 0 sp0 b 11 b 10 b 9 b 8 b 7 b 6 b 5 b 4 b 3 b 2 b 1 b 0 bit address stack register (asr) address 0h 1h 2h 3h 4h 5h 6h 7h asr0 asr1 asr2 asr3 asr4 asr5 asr6 asr7 (undefined) cannot be used stack pointer (sp) bit b 3 0 b 2 sp2 b 1 sp1 b 0 sp0 b 12 b 10 b 9 b 8 b 7 b 6 b 5 b 4 b 3 b 2 b 1 b 0 bit address stack register (asr) address 0h 1h 2h 3h 4h 5h 6h 7h asr0 asr1 asr2 asr3 asr4 asr5 asr6 asr7 (undefined) cannot be used b 11 (b) m pd17017
m pd17016, 17017 31 3.3 stack pointer (sp) 3.3.1 configuration and function of stack pointer figure 3-3 shows the configuration and function of the stack pointer. the stack pointer is a 4-bit binary counter. it specifies the address of an address stack register. the value of the stack pointer can be directly read or written by using a register manipulation instruction. figure 3-3. configuration and function of stack pointer name flag symbol b 3 0 b 2 s p 2 b 1 s p 1 b 0 s p 0 address 01h read/ write r/w 0 0 0 0 1 1 1 1 0 0 1 1 0 0 1 1 0 1 0 1 0 1 0 1 specifies address of address stack register (asr) address 0 (asr0) address 1 (asr1) address 2 (asr2) address 3 (asr3) address 4 (asr4) address 5 (asr5) address 6 (asr6) address 7 (asr7) fixed to 0 power-on clock stop ce 01 1 1 1 1 1 1 1 1 stack pointer sp on reset
m pd17016, 17017 32 3.4 operation of address stack 3.4.1 on execution of subroutine call (call addr, call @ar) or return (ret, retsk) instruction when a subroutine call instruction is executed, the value of the stack pointer is decremented by one and a return address is saved to the address stack register specified by the stack pointer. when a return instruction is executed, the contents (return address) of the address stack register specified by the stack pointer are restored to the program counter, and the value of the stack pointer is incremented by one. 3.4.2 on execution of table reference instruction (movt dbf, @ar) when a table reference instruction is executed, the value of the stack pointer is decremented by one, and a return address is saved to the address stack register specified by the stack pointer. next, the contents of the program memory specified by the address register are read to the data buffer, the contents (return address) of the address stack register specified by the stack pointer are restored to the program counter, and then the value of the stack pointer is incremented by one. 3.4.3 on acknowledging interrupt and execution of return instruction (reti) when an interrupt is acknowledged, the value of the stack pointer is decremented by one, and the return address is saved to the address stack register specified by the stack pointer. when a return instruction is executed, the contents (return address) of the address stack register specified by the stack pointer are restored to the program counter, and the value of the stack pointer is incremented by one. 3.4.4 on execution of address stack manipulation instruction (push ar, pop ar) when the push instruction is executed, the value of the stack pointer is decremented by one, and the contents of the address register are transferred to the address stack register specified by the stack pointer. when the pop instruction is executed, the contents of the address stack register specified by the stack pointer are transferred to the address register, and the value of the stack pointer is incremented by one. 3.5 notes on using address stack 3.5.1 nesting level the value of the address stack register (asr7) is undefined when the value of the stack pointer is 07h. do not use a subroutine call or interrupt exceeding level 7 without manipulating the stack; otherwise, execution returns to an undefined address.
m pd17016, 17017 33 4. data memory (ram) 4.1 outline of data memory figure 4-1 outlines the data memory. as shown in this figure, the data memory consists of a general-purpose data memory, system register, data buffer, lcd segment register, and port registers. the data memory stores data, transfers data with the peripheral hardware units, sets display data, transfers data with the ports, and controls the cpu. figure 4-1. outline of data memory peripheral hardware data transfer column address lcd segment register bank0 data buffer port register 0 1 2 3 4 5 6 7 0123456789abcdef bank1 bank2 bank3 note port data transfer lcd system register port register port register data transfer row address note bank3 is not provided on the m pd17016.
m pd17016, 17017 34 4.2 configuration and function of data memory figure 4-2 shows the configuration of the data memory. as shown in the figure, the data memory consists of banks. each bank consists of 128 nibbles with 7h row addresses and 0fh column addresses. the data memory can be divided by classification of function into the blocks explained in the following 4.2.1 through 4.2.6. the contents of the data memory can be operated, compared, judged, and transferred in 4-bit units by using a data memory manipulation instruction. table 4-1 lists the available data memory manipulation instructions. 4.2.1 system register (sysreg) the system register is allocated to addresses 74h through 7fh. because the system register is allocated to every bank, the identical system register exists at addresses 74h through 7fh of any bank. for details, refer to 5. system register (sysreg) . 4.2.2 data buffer (dbf) the data buffer is allocated to addresses 0ch through 0fh of bank0. for details, refer to 9. data buffer (dbf) . 4.2.3 lcd segment data register (lcd segment register) the lcd segment register is allocated to addresses 60h through 6fh of bank0. for details, refer to 21. lcd controller/driver . 4.2.4 port data registers (port registers) the port registers are allocated to addresses 70h through 73h of each bank. for details, refer to 15. general-purpose port . 4.2.5 general-purpose data memory the general-purpose data memory is allocated to the addresses of the data memory excluding those of the system register, lcd segment register, and port registers. (a) m pd17016 the general-purpose data memory of the m pd17016 consists of a total of 320 nibbles (320 4 bits): 96 nibbles of bank0, and 112 nibbles each of bank1 and bank2. (b) m pd17017 the general-purpose data memory of the m pd17017 consists of a total of 432 nibbles (432 4 bits): 96 nibbles of bank0, and 112 nibbles each of bank1 through bank3. 4.2.6 data memory not provided data memory areas to which nothing is actually allocated exist in the lcd segment register and part of the port registers. for the details of these data memory areas, refer to 4.4.2 notes on data memory area not provided , 15. general-purpose port , and 21. lcd controller/driver .
m pd17016, 17017 35 figure 4-2. configuration of data memory bank0 data memory 0 1 2 3 4 5 6 7 0123456789abcdef bank1 bank2 bank3 note 1 system register column address 0123456789abcdef column address 0 1 2 3 4 5 6 7 general register lcd segment register bank0 port register system register (sysreg) example address 1ah of bank0 b 3 b 2 b 1 b 0 0123456789abcdef 0 1 2 3 4 5 6 7 bank1 port register system register (sysreg) 0123456789abcdef 0 1 2 3 4 5 6 7 bank2 port register 0123456789abcdef 0 1 2 3 4 5 6 7 note 2 bank3 note 1 same system register exists. system register (sysreg) system register (sysreg) data buffer (dbf) row address row address row address row address row address note 2 note 2 note 2 notes 1. bank3 is not provided on the m pd17016. 2. bank3 does not have addresses 70h through 73h.
m pd17016, 17017 36 table 4-1. data memory manipulation instructions function instruction operation addition add addc subtraction sub subc logical and or xor compare ske skge sklt skne transfer mov ld st judgement skt skf 4.3 addressing of data memory figure 4-3 shows addressing of the data memory. an address of the data memory is specified by a bank, a row address, and a column address. the row address and column address are directly specified by using a data memory manipulation instruction. the bank is specified by the contents of the bank register. for the details of the bank register, refer to 5. system register (sysreg) . figure 4-3. addressing of data memory bank register m data memory address b 3 b 2 b 1 b 0 b 2 b 1 b 0 b 3 b 2 b 1 b 0 bank row address column address instruction operand
m pd17016, 17017 37 4.4 notes on using data memory 4.4.1 on power-on reset the contents of the general-purpose data memory are undefined on power-on reset. initialize the general-purpose data memory as necessary. 4.4.2 notes on data memory area not provided if a data memory manipulation instruction is executed to an address of the data memory area not provided, the following operations are performed. (1) device operation if a read instruction is executed, 0 is read. nothing is affected even if a write instruction is executed. (2) assembler operation assembly is performed normally. an error does not occur. (3) in-circuit emulator operation if a read instruction is executed, 0 is read. nothing is affected even if a write instruction is executed. an error does not occur.
m pd17016, 17017 38 5. system register (sysreg) 5.1 outline of system register figure 5-1 shows the location of the system memory on the data memory and the outline of the system register. as shown in this figure, the system register is allocated to addresses 74h through 7fh of each bank of the data memory. therefore, an identical system register exists at addresses 74h through 7fh of any bank. because the system register is located on the data memory, it can be manipulated by any data memory manipulation instruction. the system register consists of seven registers. figure 5-1. location on data memory and outline of system register bank3 note column address 0 1 2 3 4 5 6 7 0123456789abcdef system register bank2 bank1 bank0 data memory row address address name function 74h 75h 76h 77h 78h 79h address register (ar) window register (wr) bank register (bank) address name function 7ah 7bh 7ch 7dh 7eh 7fh index register (ix) general register pointer (rp) program status word (psword) data memory row address pointer (mp) transfers data with register file. specifies bank of data memory. controls program memory address. modifies address of data memory. specifies address of general register controls operation. note bank3 is not provided on the pd17016. m
m pd17016, 17017 39 5.2 system register list figure 5-2 shows the configuration of the system register. figure 5-2. configuration of system register address name symbol bit data 74h 75h 76h 77h 78h 79h system register address register (ar) window register (wr) bank register (bank) ar3 ar2 ar1 ar0 wr bank b 3 b 2 b 1 b 0 b 3 b 2 b 1 b 0 b 3 b 2 b 1 b 0 b 3 b 2 b 1 b 0 b 3 b 2 b 1 b 0 b 3 b 2 b 1 b 0 0 0 0 ( pd17016) 0 0 0 0 0 0 0 0 ( pd17017) m address name symbol bit data 7ah 7bh 7ch 7dh 7eh 7fh system register index register (ix) general register pointer (rp) program status word (psword) ixh mph ixm mpl ixl rph rpl psw b 3 b 2 b 1 b 0 b 3 b 2 b 1 b 0 b 3 b 2 b 1 b 0 b 3 b 2 b 1 b 0 b 3 b 2 b 1 b 0 b 3 b 2 b 1 b 0 (ix) 00 data memory row address pointer (mp) (mp) 000 b c d c m p c y zi x e (rp) m m p e 0000
m pd17016, 17017 40 5.3 address register (ar) 5.3.1 configuration of address register figure 5-3 shows the configuration of the address register. as shown in this figure, the address register consists of 16 bits, or 74h through 77h (ar3 through ar0) of the system register. the high-order 8 bits of this register of the m pd17016 are fixed to 0, and the high-order 3 bits of the address register of the m pd17017 are fixed to 0. figure 5-3. configuration of address register address name symbol bit data note power-on clock stop ce 74h 75h ar3 ar2 b 3 b 2 b 1 b 0 b 3 b 2 b 1 b 0 0 0 0 0 0 0 address register (ar) b 3 b 2 b 1 b 0 b 3 b 2 b 1 b 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ( pd17016) m ( pd17017) 76h 77h ar1 ar0 0000 m m s b l s b m s b l s b on reset remark power-on : power-on reset clock stop : execution of clock stop instruction ce : ce reset note bits marked 0 are fixed to 0.
m pd17016, 17017 41 5.3.2 function of address register the address register specifies a program memory address when a table reference (movt dbf, @ar), stack manipulation (push ar, pop ar), indirect branch (br @ar) or indirect subroutine call (call @ar) instruction is executed. a dedicated instruction (inc ar) that can increment the value of the address register by one is also available. the following paragraphs (1) through (5) explain the operations to be performed when the respective instructions are executed. the address register can set the following range of the program memory addresses. m pd17016 : 0000h through 00ffh m pd17017 : 0000h through 1efbh do not set an address other than above to the address register. (1) table reference instruction (movt dbf, @ar) this instruction reads the constant data (16-bit) of the program memory address specified by the contents of the address register to the data buffer. (2) stack manipulation instructions (push ar, pop ar) when the push ar instruction is executed, the value of the stack pointer is decremented by one, and the contents of the address register (ar) are stored to the address stack register specified by this value of the stack pointer. when the pop ar instruction is executed, the contents of the address stack register specified by the stack pointer are transferred to the address register, and the value of the stack pointer are incremented by one. (3) indirect branch instruction (br @ar) this instruction branches execution to the program memory address specified by the contents of the address register. (4) indirect subroutine call instruction (call @ar) this instruction calls the subroutine at the program memory address specified by the contents of the address register. (5) address register increment instruction (inc ar) this instruction increments the contents of the address register by one. (a) with m pd17016 because the address register of the m pd17016 consists of 8 bits, its contents are cleared to 0000h if the inc ar instruction is executed when the contents of the address register are 00ffh. (b) with m pd17017 because the address register of the m pd17017 consists of 13 bits, its contents are cleared to 0000h if the inc ar instruction is executed when the contents of the address register are 1fffh. 5.3.3 address register and data buffer the address register can transfer data via the data buffer as part of the peripheral hardware. for details, refer to 9. data buffer (dbf) .
m pd17016, 17017 42 5.4 window register (wr) 5.4.1 configuration of window register figure 5-4 shows the configuration of the window register. as shown in the figure, the window register consists of 4 bits at address 78h of the system register. figure 5-4. configuration of window register address name symbol bit data power-on clock stop ce 78h window register (wr) wr b 3 b 1 b 0 undefined holds previous status m s b on reset l s b b 2 5.4.2 function of window register the window register is used to transfer data with register file (rf) that is explained later. to transfer data between the window register and register file, dedicated instructions peek wr, rf and poke rf, wr are used (rf: address of register file). the following paragraphs (1) and (2) explain the operations to be performed when each of these instructions is executed. also refer to 8. register file (rf) . (1) peek wr, rf instruction when this instruction is executed, the contents of the register file addressed by rf are transferred to the window register. (2) poke rf, wr instruction when this instruction is executed, the contents of the window register are transferred to the register file addressed by rf.
m pd17016, 17017 43 5.5 bank register (bank) 5.5.1 configuration of bank register figure 5-5 shows the configuration of the bank register. as shown in the figure, the bank register consists of 4 bits at address 79h (bank) of the system register. actually, however, this register is a 2-bit register because the high-order 2 bits are always fixed to 0. figure 5-5. configuration of bank register address name symbol bit data power-on clock stop ce 79h bank register (bank) bank b 3 0 b 2 0 b 1 b 0 0 0 0 m s b on reset l s b 5.5.2 function of bank register the bank register specifies a bank of the data memory. table 5-1 shows the relation between the value of the bank register and a bank of the data memory specified by each value of the bank register. because the bank register exists on the system register, its contents can be rewritten no matter which bank may be currently specified. in other words, the bank register can be manipulated independently of the current status of the bank. table 5-1. specifying bank of data memory note bank3 is not provided on the m pd17016. do not set this bank with the m pd17016. bank register (bank) b 3 0 0 0 0 b 2 0 0 0 0 b 1 0 0 1 1 b 0 0 1 0 1 bank0 bank1 bank2 bank3 note data memory bank
m pd17016, 17017 44 5.6 index register (ix) and data memory row address pointer (mp: memory pointer) 5.6.1 configuration of index register and data memory row address pointer figure 5-6 shows the configuration of the index register and data memory row address pointer. as shown in the figure, the index register consists of an index register (ix) and an index enable flag (ixe). ix is a 11-bit register consisting of the low-order 3 bits (ixh) of system register address 7ah, and addresses 7bh and 7ch (ixm and ixl). ixe is the least significant bit of address 7fh (psw). the data memory row address pointer (memory pointer) consists of a data memory row address pointer, which consists of 7 bits with the low-order 3 bits of address 7ah (mph) and address 7bh (mpl), and a data memory row address pointer enable flag (memory pointer enable flag: mpe), which is the most significant bit of address 7ah (mph). in other words, the high-order 7 bits of the index register are shared with the data memory row address pointer. note, however, that the high-order 2 bits of the index register and data memory row address pointer (bits b 2 and b 1 of address 7ah) are always fixed to 0. figure 5-6. configuration of index register and data memory row address pointer address name symbol bit data power-on clock stop ce 7ah index register (ix) ixh mph b 3 b 2 0 b 1 0 b 0 0 0 0 7bh ixm mpl b 3 b 2 b 1 b 0 0 0 0 7ch ixl b 3 b 2 b 1 b 0 0 0 0 7eh b 3 b 2 b 1 b 0 7fh psw b 3 b 2 b 1 b 0 0 0 0 memory pointer (mp) program status word (psword) ix mp on reset m s b m s b l s b i x e l s b
m pd17016, 17017 45 5.6.2 functions of index register and data memory row address pointer the index register and data memory row address pointer modify the addresses of the data memory. the following paragraphs (1) and (2) explains the functions of the index register and data memory row address pointer, respectively. a dedicated instruction (inc ix) that can increment the value of the address register by one is also available. for details on address modification, refer to 7. alu (arithmetic logic unit) block . (1) index register the index register modifies a specified data memory address according to the contents of the index register when a data memory manipulation instruction is executed. this modification, however, is valid only when the ixe flag is set to 1. to modify an address, the bank, row address, and column address of the data memory are ored with the contents of the index register, and the instruction is executed to the data memory whose address (called an actual address) is specified by the result of this or operation. all the data memory manipulation instructions are subject to address modification by the index register. the following instructions are not subject to modification by the index register. inc ar rorc r inc ix call addr movt dbf, @ar call @ar push ar ret pop ar retsk peek wr, rf reti poke rf, wr ei get dbf, p di put p, dbf stop s br addr halt h br @ar nop (2) data memory row address pointer the data memory row address pointer modifies the address at the indirect transfer destination when a general register indirect transfer instruction (mov @r, m or mov m, @r) is executed. however, this modification is valid only when the mpe flag is set to 1. to modify the address, the bank and row address at the transfer destination are replaced with the contents of the data memory row address pointer. instructions other than the general register indirect transfer instructions are not subject to address modification. (3) index register increment instruction (inc ix) this instruction increments the contents of the index register by one. because the index register is configured of 9 bits, the contents of the index register are cleared to 000h if the inc ix instruction is executed when the contents of the index register are 1ffh.
m pd17016, 17017 46 5.7 general register pointer (rp) 5.7.1 configuration of general register pointer figure 5-7 shows the configuration of the general register pointer. as shown in this figure, the general register pointer consists of 7 bits: 4 bits of address 7dh (rph) of the system register and the high-order 3 bits of address 7eh (rpl). however, because the high-order 3 bits of address 7e are always fixed to 0, actually the low-order 4 bits of this register (the lowest 1 bit of address 7dh and the high-order 3 bits of address 7eh) are valid. figure 5-7. configuration of general register pointer address name symbol bit data power-on clock stop ce 7dh 7eh general register pointer (rp) rph rpl b 3 0 b 2 0 b 1 0 b 0 b 3 b 2 b 1 b 0 0 0 0 0 0 0 m s b on reset l s b b c d
m pd17016, 17017 47 5.7.2 function of general register pointer the general register pointer specifies a general register on the data memory. figure 5-8 shows the address of the general register specified by the general register pointer. as shown in the figure, the high-order 4 bits of the general register pointer (rph: address 7dh) specify a bank, and the low-order 3 bits (rpl: address 7eh) specify a row address. because the valid number of bits of the general register pointer is 4, the row addresses (0h through 7h) of bank0 and bank1 can be specified as general registers. for the details on the operations of the general registers, refer to 6. general register (gr) . figure 5-8. address of general register specified by general register pointer general register pointer (rp) rph rpl b 3 0 b 2 0 b 1 0 b 0 b 3 b 2 b 1 b 0 specifies row address of each bank bank bank0 bank1 row address 0h 1h 2h 3h 4h 5h 6h 7h 0000 0 0 0 1 1 1 1 0 0 0 0 1 1 1 1 0 0 1 1 0 0 1 1 0 1 0 1 0 1 0 1 m s b l s b b c d specifies bank caution because the valid number of bits of the general register pointer is 4, bank2 and bank3 cannot be specified. 5.7.3 notes on using general register pointer the least significant bit of address 7eh (rpl) to which the general register pointer is allocated is used as the bcd flag of the program status word. when rewriting the value of rpl, therefore, pay attention to the value of the bcd flag.
m pd17016, 17017 48 5.8 program status word (psword) 5.8.1 configuration of program status word figure 5-9 shows the configuration of the program status word. as shown in the figure, the program status word consists of 5 bits: the least significant bit of address 7eh (rpl) of the system register and the 4 bits of the address 7fh (psw). the program status word consists of five flags, each of which functions independently: bcd (bcd), compare (cmp), carry (cy), zero (z), and index enable (ixe) flags. figure 5-9. configuration of program status word address name symbol bit data power-on clock stop ce 7eh 7eh program status word (psword) rpl psw b 3 b 2 b 1 b 0 b 3 b 2 b 1 b 0 0 0 0 0 0 0 (rp) b c d on reset c m p c y zi x e
m pd17016, 17017 49 5.8.2 function of program status word the program status word is a register that sets the condition of an operation or transfer instruction of the alu (arithmetic logic unit) or indicates the result of an operation executed. table 5-2 outlines the function of each flag of the program status word. for details, refer to 7. alu (arithmetic logic unit) block . table 5-2. functional outline of program status word 5.8.3 notes on using program status word if an arithmetic operation (addition or subtraction) instruction is executed to the program status word, the result of the arithmetic operation is stored to the program status word. for example, even if an operation that causes a carry to occur is executed, if the result of the operation is 0000b, 0000b is stored to psw. 5.9 notes on using system register the data of the system register fixed to 0 is not affected even if a write instruction is executed to it. this data is always 0 when it is read. program status word (psword) rpl psw b 3 b 2 b 1 b 0 b c d b 3 c m p b 2 c y b 1 z b 0 i x e flag name index enable flag (ixe) zero flag (z) carry flag (cy) compare flag (cmp) bcd flag (bcd) function (rp) this flag modifies address of data memory when data memory manipulation instruction is executed. 0 : does not modify 1 : modifies this flag indicates that result of arithmetic operation executed is 0. note that status of 0 or 1 differs depending on content of compare flag. this flag indicates occurrence of carry or borrow as result of execution of addition or subtraction instruction. it is reset to 0 if carry/borrow does not occur; it is set to 1 if carry/borrow occurs. this flag is also used as sift bit of rorc r instruction. this flag is used to not store result of arithmetic operation to data memory or general register. 0 : result stored 1 : result not stored this flag is used to execute arithmetic operation in decimal. 0 : executes binary operation 1 : executes decimal operation
m pd17016, 17017 50 6. general register (gr) 6.1 outline of general register figure 6-1 outlines the general register. as shown in the figure, the general register consists of a general register pointer and general register body. the bank and row address of the general register body are specified by the general register pointer. the general register body is used to transfer data and execute operation between data memory addresses. figure 6-1. outline of general register bank3 note column address system register bank2 bank1 bank0 data memory general register transfer, operation general register pointer row address note bank3 is not provided to the m pd17016. caution because the valid number of bits of the general register pointer is 4, bank2 and bank3 cannot be specified. 6.2 general register body the general register body consists of 16 nibbles (16 x 4 bits) at the same row addresses on the data memory. for the range of the banks and row addresses that can be specified by the general register pointer and general register, refer to 5.7 general register pointer (rp) . the 16 nibbles of the same row address specified as a general register executes operation and transfers data with the data memory with a single instruction. in other words, operation or transfer between data memory addresses can be executed with a single instruction. the general register can be controlled by a data memory manipulation instruction like the other data memory areas.
m pd17016, 17017 51 6.3 address generation of general register by instructions the following subsections 6.3.1 and 6.3.2 explains how the addresses of the general register are generated when each instruction is executed. for the details of the operation of each instruction, refer to 7. alu (arithmetic logic unit) block . 6.3.1 addition (add r, m, addc r, m), subtraction (sub r, m, subc r, m), logical operation (and r, m, or r, m, xor r, m), direct transfer (ld r, m, st m, r), and rotation processing (rorc r) instructions table 6-1 shows the address of general register r specified by operand r of an instruction. only specify a column address as operand r. table 6-1. address generation of general register contents of general register pointer r r general register address b 3 b 2 b 1 b 0 b 2 b 1 b 0 b 3 b 2 b 1 b 0 bank row address column address 6.3.2 indirect transfer (mov @r,m, mov m, @r) instructions table 6-2 shows the address of the general register r specified by operand r of an instruction and an indirect transfer address specified by @r. table 6-2. address generation of general register contents of general register pointer r r general register address b 3 b 2 b 1 b 0 b 2 b 1 b 0 b 3 b 2 b 1 b 0 bank row address column address same as data memory contents of r @r indirect transfer address
m pd17016, 17017 52 6.4 notes on using general register 6.4.1 row address of general register note that because the row address of the general register is specified by the general register pointer, the bank currently specified may differ from the bank of the general register. 6.4.2 operation between general register and immediate data no instruction that executes an operation between the general register and immediate data is provided. to execute an operation between the general register and immediate data, the general register must be treated as a data memory area.
m pd17016, 17017 53 7. alu (arithmetic logic unit) block 7.1 outline of alu block figure 7-1 outlines the alu block. as shown in the figure, the alu block consists of an alu, temporary registers a and b, program status word, decimal adjustment circuit, and data memory address control circuit. the alu operates, judges, compares, rotates, and transfers 4-bit data on the data memory. figure 7-1. outline of alu block data bus address control data memory index modification memory pointer temporary register a temporary register b program status word carry/borrow/ zero detection/decimal/ storage specification alu ? arithmetic operation ? logical operation ? bit judgment ? comparison ? rotation processing ? transfer decimal adjustment
m pd17016, 17017 54 7.2 configuration and function of each block 7.2.1 alu the alu executes arithmetic or logical operation, bit judgment, comparison, rotation processing, and transfer of 4-bit data according to an instruction specified by the program. 7.2.2 temporary registers a and b temporary registers a and b temporarily store 4-bit data. these registers are automatically used when an instruction is executed and are not controlled by the program. 7.2.3 program status word the program status word controls the operation of the alu and stores the status of the alu. for the details on the program status word, refer to 5.8 program status word (psword) . 7.2.4 decimal adjustment circuit if the bcd flag of the program status word is set to 1 as a result of an arithmetic operation executed, the arithmetic operation result is converted into a decimal number by the decimal adjustment circuit. 7.2.5 address control circuit the address control circuit specifies an address of the data memory. at this time, address modification by the index register and data memory row address pointer is also controlled. 7.3 alu processing instruction list table 7-1 lists the alu operations when each instruction is executed. table 7-2 shows modification of data memory addresses by the index register and data memory row address pointer. table 7-3 shows the decimal adjustment data when a decimal operation is executed.
m pd17016, 17017 55 ------------------------------------------------------------------------------------------------------------------------------- ---------- table 7-1. list of alu processing instruction operations alu instruction difference in operation due to program status word (psword) address modification function value of value of arithmetic operation of operation of z flag index memory bcd flag cmp flag operation cy flag pointer addition add r, m 0 0 stores result of set if carry or set if result of operation executed not m, #n4 binary operation. borrow occurs; is 0000b; otherwise, reset. executed addc r, m 0 1 does not store otherwise, reset. holds status if result of m, #n4 result of binary operation is 0000b; operation. otherwise, reset. subtrac- sub r, m 1 0 stores result of set if result of operation is tion m, #n4 decimal operation. 0000b; otherwise, reset. subc r, m 1 1 does not store holds status if result of m, #n4 result of decimal operation is 0000b; otherwise, operation. reset. logical or r, m any any not affected holds previous holds previous status. executed not operation m, #n4 (held) (held) status. executed and r, m m, #n4 xor r, m m, #n4 judgment skt m, #n any any not affected holds previous holds previous status. executed not skf m, #n (held) (reset) status. executed compare ske m, #n4 any any not affected holds previous holds previous status. executed not skne m, #n4 (held) (held) status. executed skge m, #n4 sklt m, #n4 transfer ld r, m any any not affected holds previous holds previous status executed not st m, r (held) (held) status executed mov m, #n4 @r, m executed m, @r rotation rorc r any any not affected value of general holds previous value not not (held) (held) register b 0 executed executed
m pd17016, 17017 56 table 7-2. modification of data memory address and modification of indirect transfer address by index register and data memory row address pointer b 3 b 2 b 1 b 0 b 2 b 1 b 0 b 3 b 2 b 1 b 0 b 3 b 2 b 1 b 0 b 2 b 1 b 0 b 3 b 2 b 1 b 0 b 3 b 2 b 1 b 0 b 2 b 1 b 0 b 3 b 2 b 1 b 0 general register address specified by r data memory address specified by m indirect transfer address specified by @r bank row address column address bank row address column address bank row address column address rp r bank m bank m r (r) ditto mp (r) ditto bank m bank m r ix (r) or mp (r) ditto ditto ditto mpe 0 1 0 1 ixe 0 0 1 1 ixh, ixm logical or logical bank : bank register ix : index register ixe : index enable flag ixh : bits 10 through 8 of index register ixm : bits 7 through 4 of index register ixl : bits 3 through 0 of index register m : data memory address indicated by m r , m c m r : data memory row address (high-order) m c : data memory column address (low-order) mp : data memory row address pointer mpe : memory pointer enable flag r : general register column address rp : general register pointer (x) : contents addressed by x x : direct address such as m and r
m pd17016, 17017 57 table 7-3. decimal adjustment data operation result hexadecimal addition decimal addition operation result hexadecimal subtraction decimal subtraction cy operation result cy operation result cy operation result cy operation result 0 0 0000b 0 0000b 0 0 0000b 0 0000b 1 0 0001b 0 0001b 1 0 0001b 0 0001b 2 0 0010b 0 0010b 2 0 0010b 0 0010b 3 0 0011b 0 0011b 3 0 0011b 0 0011b 4 0 0100b 0 0100b 4 0 0100b 0 0100b 5 0 0101b 0 0101b 5 0 0101b 0 0101b 6 0 0110b 0 0110b 6 0 0110b 0 0110b 7 0 0111b 0 0111b 7 0 0111b 0 0111b 8 0 1000b 0 1000b 8 0 1000b 0 1000b 9 0 1001b 0 1001b 9 0 1001b 0 1001b 10 0 1010b 1 0000b 10 0 1010b 1 1100b 11 0 1011b 1 0001b 11 0 1011b 1 1101b 12 0 1100b 1 0010b 12 0 1100b 1 1110b 13 0 1101b 1 0011b 13 0 1101b 1 1111b 14 0 1110b 1 0100b 14 0 1110b 1 1100b 15 0 1111b 1 0101b 15 0 1111b 1 1101b 16 1 0000b 1 0110b C16 1 0000b 1 1110b 17 1 0001b 1 0111b C15 1 0001b 1 1111b 18 1 0010b 1 1000b C14 1 0010b 1 1100b 19 1 0011b 1 1001b C13 1 0011b 1 1101b 20 1 0100b 1 1110b C12 1 0100b 1 1110b 21 1 0101b 1 1111b C11 1 0101b 1 1111b 22 1 0110b 1 1100b C10 1 0110b 1 0000b 23 1 0111b 1 1101b C9 1 0111b 1 0001b 24 1 1000b 1 1110b C8 1 1000b 1 0010b 25 1 1001b 1 1111b C7 1 1001b 1 0011b 26 1 1010b 1 1100b C6 1 1010b 1 0100b 27 1 1011b 1 1101b C5 1 1011b 1 0101b 28 1 1100b 1 1010b C4 1 1100b 1 0110b 29 1 1101b 1 1011b C3 1 1101b 1 0111b 30 1 1110b 1 1100b C2 1 1110b 1 1000b 31 1 1111b 1 1101b C1 1 1111b 1 1001b remark the operation results in the shaded portion are not correctly adjusted by the decimal adjustment circuit.
m pd17016, 17017 58 7.4 notes on using alu 7.4.1 notes on using operation to program status word if an arithmetic operation is executed on the program status word, the result of the arithmetic operation is stored in the program status word. the cy and z flags of the program status word are set or reset depending on the result of the arithmetic operation. if an arithmetic operation is executed on the program status word itself, the result of the operation is stored in the program status word, which makes it impossible to judge occurrence of a carry or a borrow, or whether the result of the operation is zero. if the cmp flag is set, however, the result of the operation is not stored in the program status word, so that the cy and z flags are set or reset normally. 7.4.2 notes on using decimal operation a decimal operation can be executed only if the result falls within the following range: (1) result of addition : 0 to 19 in decimal (2) result of subtraction : 0 to 9 or C10 to C1 in decimal if a decimal operation is executed exceeding this range, the cy flag is set, and the result is a value greater than 1010b (0ah).
m pd17016, 17017 59 8. register file (rf) 8.1 outline of register file figure 8-1 outlines the register file. as shown in the figure, the register file consists of control registers existing on a space different from that of the data memory, and a portion overlapping the data memory. the control registers set the conditions of the peripheral hardware units. data are read from or written to the register file via the window register. figure 8-1. outline of register file control registers (separate space from data memory) (space same as data memory) data is manipulated via window register 0 1 2 3 4 5 6 7 system register window register peripheral hardware register file row address
m pd17016, 17017 60 8.2 configuration and function of register file figure 8-2 shows the configuration of and relation with the data memory of the register file. addresses are allocated to the register file in 4-bit units, like the data memory, and the register file has a total of 128 nibbles with row addresses 0h through 7h and column addresses 0h through 0fh. control registers that set the conditions of the peripheral hardware units are allocated to addresses 00h through 3fh. addresses 40h through 7fh overlap the data memory. to put it another way, the addresses 40h through 7fh of the register file are the memory addresses of the bank currently selected of the data memory. these addresses, 40h through 7fh, can be treated in the same manner as the normal data memory areas, except that they can be manipulated by a register file manipulation instruction (peek wr, rf or poke rf, wr), because they overlap the data memory. figure 8-2. configuration of register file and its relation with data memory column address bank0 0 1 2 3 4 5 6 7 0123456789abcdef system register data memory bank1 bank2 bank3 note 0 1 2 3 control register register file row address note bank3 is not provided to the m pd17016.
m pd17016, 17017 61 8.2.1 register file manipulation instructions (peek wr, rf and poke rf, wr) data are read from or written to the register file via the window register in the system register by using a register file manipulation instruction (peek wr, rf or poke rf, wr). the operation of each instruction is explained below. (1) peek wr, rf this instruction reads the data of the register file addressed by rf to the window register. (2) poke rf, wr this instruction writes the data of the window register to the register file addressed by rf. 8.3 control registers figure 8-3 shows the configuration of the control registers. as shown in this figure, a total of 64 nibbles (64 words 4 bits) at addresses 00h through 3fh of the register file can be used as control registers. of these nibbles, however, 19 nibbles are actually used. the remaining 45 nibbles are unused registers that are prohibited from being read or written. each control register has an attribute of 1 nibble, and is classified into four types: read/write (r/w), read- only (r), write-only (w), and read-and-reset (r & reset). nothing is changed even if data is written to a read-only (r and r & reset) register. an undefined value is read if a write-only (w) register is read. of the 4-bit data in 1 nibble, the bit fixed to 0 is always 0 when it is read or written. the 45 nibbles of unused registers are undefined when they are read, and nothing is changed when data is written to them.
m pd17016, 17017 62 figure 8-3. configuration of control registers (1/2) colum address name symbol read/ write row address item stack pointer (sp) 01234567 s p 3 serial i/o mode select i/f count gate judge pll unlock ff judge a/d converter compare judge ce pin level judge 0 (8) name symbol read/ write 1 (9) name symbol read/ write 2 (a) name symbol read/ write 3 (b) ( s p 2 ( s p 1 ( s p 0 ( s i o 1 t s s i o 1 h i z s i o 1 c k 1 s i o 1 c k 0 000 i f c g o s t t 000p l l u l 000c e 000a d c c m p r/w r/w r r & reset r r if counter mode select i f c m d 1 r/w if counter control p l l m d 3 r/w pll reference mode select p l l r f c k 3 r/w lcd mode select a/d converter channel select key input judge timer carry ff judge pll mode select port 0c group i/o select port 1a bit i/o select port 0a bit i/o select port 0b bit i/o select r/w r/w w r/w r/w r & reset r & reset r & reset i f c m d 0 i f c c k 1 i f c c k 0 a d c c h 3 a d c c h 2 a d c c h 1 a d c c h 0 000k e y j 000b t m 0 c y l c d e n k s e n 0 0 p l l m d 2 p l l m d 1 p l l m d 0 00 i f c s t r t i f c r e s 000p 0 c g i o p l l r f c k 2 p l l r f c k 1 p l l r f c k 0 p 1 a b i o 3 p 1 a b i o 2 p 1 a b i o 1 p 1 a b i o 0 p 0 b b i o 3 p 0 b b i o 2 p 0 b b i o 1 p 0 b b i o 0 p 0 a b i o 3 p 0 a b i o 2 p 0 a b i o 1 p 0 a b i o 0 r/w ( ( ( (
m pd17016, 17017 63 figure 8-3. configuration of control registers (2/2) timer mode select 8 9abcdef b t m 1 c k 1 b t m 1 c k 0 b t m 0 c k 1 b t m 0 c k 0 r/w
m pd17016, 17017 64 table 8-1. outline of peripheral hardware control functions of control registers (1/3) peripheral control register peripheral hardware control function on reset hardware name address read/ b3 functional outline set value power clock ce write b2 symbol on stop b1 b0 stack stack pointer 01h r/w (sp3) 0 (sp) (sp2) (sp1) stack pointer (sp0) timer timer mode 09h r/w btm1ck1 select btm1ck0 btm0ck1 btm0ck0 timer carry ff 17h r & 0 judge reset 0 0 btm0cy detects timer carry ff 0: ff reset, 1: ff set 0 1 1 pin ce pin level 07h r 0 judge 0 0 ce detects ce pin status 0: low level, 1: high level C C C pll frequency pll unlock 05h r & 0 synthesizer ff judge reset 0 0 0: lock, 1: unlock pllul detects unlock ff status read & reset pll mode select 21h r/w pllmd3 0 pllmd2 0 pllmd1 pllmd0 pll reference 31h r/w pllrfck3 mode select pllrfck2 pllrfck1 pllrfck0 a/d converter a/d converter 14h r/w adcch3 0 channel select adcch2 adcch1 0:ad 0 1:ad 1 2:ad 2 3:ad 3 adcch0 4:ad 4 5:ad 5 6:7: input port a/d converter 06h r 0 compare judge 0 0 adccmp detects result of 0:v ref >v adcin undefined retained retained comparison by 1:v ref m pd17016, 17017 65 table 8-1. outline of peripheral hardware control functions of control registers (2/3) peripheral control register peripheral hardware control function on reset hardware name address read/ b3 functional outline set value power clock ce write b2 symbol on stop b1 b0 general- port 0c group 27h r/w 0 purpose port i/o select 0 0 p0cgio sets synchronously 0: input, 1: output 0 0 0 input/output mode of p0c 3 -p0c 0 pins port 1a bit i/o 35h r/w p1abio3 p1a 3 pin select p1abio2 p1a 2 pin p1abio1 p1a 1 pin p1abio0 p1a 0 pin port 0b bit i/o 36h r/w p0bbio3 p0b 3 pin select p0bbio2 p0b 2 pin p0bbio1 p0b 1 pin p0bbio0 p0b 0 pin port 0a bit i/o 37h r/w p0abio3 p0a 3 pin select p0abio2 p0a 2 pin p0abio1 p0a 1 pin p0abio0 p0a 0 pin serial serial i/o mode 02h r/w sio1ts sets start of serial interface. 0: does not operate, 1: starts interface select sio1hiz sets p0b 1 /so pin. 0: general-purpose port, 1: serial out sio1ck1 sets clock of sio1ck0 serial interface. frequency if counter gate 04h r 0 counter judge 0 0 ifcgostt detects opening/ 0: close, 1: open 0 undefined undefined closing of gate of frequency counter if counter mode 12h r/w ifcmd1 select ifcmd0 ifcck1 ifcck0 if counter control 23h r/w 0 0 ifcstrt specifies start of 0: nop instruction, 1: start 0 0 retained frequency counter. ifcres specifies data 0: nop instruction, 1: reset reset of frequency counter. 0: input, 1: output 0 0 0 ------------------------------- setting prohibited 00 0 0 0 retained --------------- --------------- --------------- --------------- --------------- --------------- --------------- --------------- --------------- --------------- --------------- --------------- sets input/ output mode of each port pin --------------- --------------- --------------- --------------- --------------- --------------- --------------- --------------- --------------- selects frequency counter/beep mode. sets gate time of frequency counter. --------------- --------------- --------------- 0011 external 75 khz 150 khz 450 khz 0101 0011 beep fmif amif 0101 0011 1 ms 4 ms 8 ms open 0111 ------------------------------- -------------------------------
m pd17016, 17017 66 table 8-1. outline of peripheral hardware control functions of control registers (3/3) peripheral control register peripheral hardware control function on reset hardware name address read/ b3 functional outline set value power clock ce write b2 symbol on stop b1 b0 lcd driver lcd mode select 10h r/w 0 0 ksen sets key source 0: key source off, 0 0 retained signal output. 1: key source on lcden sets lcd 0: display off, display output. 1: display on key input judge 16h r & 0 reset 0 0 keyj detects key input 0: no latch, 1: latch 0 undefined undefined latch of lcd key source 8.4 notes on using register file bear in mind the following points (1) through (3) when manipulating the write-only registers (w), read-only registers (r), and unused registers of the control registers (addresses 00h through 3fh of the register file). (1) when a write-only register is read, an undefined value is read. (2) nothing is changed even if data is written to a read-only register. (3) an undefined value is read if an unused register is read. nothing is changed even if data is written to an unused register. --------------- --------------- --------------- --------------- --------------- ---------------
m pd17016, 17017 67 9. data buffer (dbf) 9.1 outline of data buffer figure 9-1 outlines the data buffer. the data buffer is located on the data memory and has the following two functions: (1) reads constant data on program memory (table reference) (2) transfers data with peripheral hardware unit figure 9-1. outline of data buffer data buffer data write (put) data read (get) table reference (movt) peripheral hardware constant data program memory
m pd17016, 17017 68 9.2 data buffer 9.2.1 configuration of data buffer figure 9-2 shows the configuration of the data buffer. as shown in the figure, the data buffer consists of a total of 16 bits at addresses 0ch through 0fh of bank 0 on the data memory. the 16-bit data consists of bit b 3 at address 0ch as the msb and bit b 0 at address 0fh as the lsb. because the data buffer is located on the data memory, it can be manipulated by all data memory manipulation instructions. figure 9-2. configuration of data buffer column address bank0 0 1 2 3 4 5 6 7 bank1 7 data memory bank2 7 bank3 note 7 system register data buffer (dbf) address bit bit signal data b 3 b 15 b 2 b 14 b 1 b 13 b 0 b 12 dbf3 0ch b 3 b 11 b 2 b 10 b 1 b 9 b 0 b 8 dbf2 0dh b 3 b 7 b 2 b 6 b 1 b 5 b 0 b 4 dbf1 0ed b 3 b 3 b 2 b 2 b 1 b 1 b 0 b 0 dbf0 0fh data memory data buffer note bank3 is not provided on the pd17016 0123456789abcdef row address m s b l s b data m
m pd17016, 17017 69 9.2.2 table reference instruction (movt dbf, @ar) this instruction reads the contents of the program memory addressed by the contents of the address register to the data buffer. one stack level is used when the table reference instruction is used. with the m pd17017 all the addresses of the program memory can be referenced by this instruction, but with the m pd17016 only the address 0000h through 00ffh can be referenced. 9.2.3 peripheral hardware control instructions (put, get) the operations of the put and get instructions are as follows: (1) get dbf, p this instruction reads the data of the peripheral register addressed by p to the data buffer. (2) put p, dbf this instruction sets the data of the data buffer to the peripheral register addressed by p. 9.3 peripheral hardware and data buffer list table 9-1 lists the peripheral hardware units and the functions of the data buffer.
m pd17016, 17017 70 table 9-1. relations between peripheral hardware and data buffer (1/2) peripheral hardware peripheral register that transfers data with data buffer name symbol peripheral execution of address put/get instruction a/d converter a/d converter data register adcr 02h put/get serial interface serial interface 1 presettable shift register sio1sfr 03h put/get (sio1) d/a converter pwm 0 pin pwm data register 0 pwmr0 05h put/get (pwm output) pwm 1 pin pwm data register 1 pwmr1 06h address register (ar) address register ar 40h put/get pll frequency synthesizer pll data register pllr 41h put/get key source controller/decoder key source data register ksr 42h put/get frequency counter if counter data register ifc 43h get -----------------------------------------------------------------------------------------------------
m pd17016, 17017 71 table 9-1. relations between peripheral hardware and data buffer (2/2) function number of i/o number of bits outline bits of data buffer actually used 8 6 x C 0.5 sets compare voltage v ref data of a/d converter v ref = v dd , 1 x 63 64 8 8 sets serial out data and reads serial in data. 8 8 sets duty factor of output signal of d/a converter. x + 0.25 duty d = 100 %, 0 x 255 256 frequency f = 878.9 hz 16 13 note transfers data with address register. 16 16 sets division ratio (n value) of pll. 16 16 sets output data of key source signal. 16 16 reads count value of frequency counter. note 8 bits in the case of the m pd17016.
m pd17016, 17017 72 9.4 notes on using data buffer bear in mind the following points (1) through (3) concerning unused peripheral address and write-only peripheral registers (put only) and read-only peripheral registers (get only) when transferring data with the peripheral hardware units via the data buffer. (1) when a write-only register is read, an undefined value is read. (2) nothing is changed even if data is written to a read-only register. (3) an undefined value is read if an unused register is read. nothing is changed even if data is written to an unused register.
m pd17016, 17017 73 10. interrupt 10.1 outline of interrupt block figure 10-1 outlines the interrupt block. as shown in the figure, the interrupt block temporarily stops the program currently being executed in response to an interrupt request output from any peripheral hardware unit and branches execution to an interrupt vector address. the interrupt block consists of an interrupt control block for each peripheral hardware unit, interrupt enable flip-flop that enables all the interrupts, stack pointer that is controlled when an interrupt is acknowledged, address stack register, program counter, and system register stack. the interrupt control block of each peripheral hardware unit consists of an interrupt request flag (irqxxx) that detects each interrupt request, interrupt permission flag (ipxxx) that enables each interrupt, and vector address generator (vag) that specifies a vector address when an interrupt is acknowledged. the peripheral hardware units that have an interrupt function are as follows: ? int 0 pin (rising-edge detection) ? timer figure 10-1. outline of interrupt block interrupt control block timer int 0 pin iptm flag irqtm flag vector address generator 03h program counter address stack register stack pointer system register interrupt stack register interrupt enable flip-flop di, ei instruction ip0 flag irq0 flag vector address generator 05h
m pd17016, 17017 74 10.2 interrupt control block the interrupt control block is provided to each peripheral hardware unit and detects an interrupt request, enables the interrupt, and generates a vector address when the interrupt is acknowledged. 10.2.1 configuration and function of interrupt request flag (irq ) each interrupt request flag (irq ) is set to 1 when an interrupt request is issued from the corresponding peripheral hardware unit, and is reset to 0 when the interrupt is acknowledged. it cannot be set by software. once this flag has been set to 1, it is not reset until the corresponding interrupt is acknowledged or an interrupt request reset macro is executed. if more than one interrupt request is issued at the same time, the interrupt request flag corresponding to the interrupt that has not been acknowledged is not reset. table 10-1 shows the software macros that reset interrupt requests. these macros are defined in the device file and can be used by includeing the files supplied with the device file (d17016.inc for the m pd17016 and d17017.inc for the m pd17017) on the source program. table 10-1. software macros that reset interrupt requests function macro name resets timer interrupt request. clr1_irqtm resets int 0 pin interrupt request. clr1_irq0 caution if the above macros are used, the contents of the window register are destroyed. if an embedded macro instruction is used immediately before the above macro instructions, an object error occurs when the source file is assembled and then loaded to the in-circuit emulator. to use an embedded macro instruction immediately before the above macro instructions, insert a comment statement between them. moreover, while either of the above macro instructions is executed, the other interrupt request cannot be acknowledged. for details, refer to 10.11 notes on using interrupt.
m pd17016, 17017 75 10.2.2 configuration and function of interrupt permission flag (ip ) each interrupt permission flag enables the interrupt of the corresponding peripheral hardware unit. so that an interrupt is acknowledged, all the following three conditions must be satisfied. ? the interrupt must be enabled by the corresponding interrupt permission flag. ? an interrupt request must be issued by the corresponding interrupt request flag. ? the ei instruction (that enables all the interrupts) must be executed. enabling or disabling an interrupt is controlled by a software macro. table 10-2 lists the available software macros. these macros are defined in the device file and can be used by includeing the files supplied with the device file (d17016.inc for the m pd17016 and d17017.inc for the m pd17017) on the source program. table 10-2. software macros enabling/disabling interrupts function macro format enables timer interrupt set1_iptm enables int 0 pin interrupt set1_ip0 enables timer interrupt and int 0 pin interrupt set2_iptm_ip0 disables timer interrupt clr1_iptm disables int 0 pin interrupt clr1_ip0 disables timer interrupt and intp 0 pin interrupt clr2_iptm_ip0 disables timer interrupt and enables int 0 pin interrupt init_not_iptm_ip0 enables timer interrupt and disables int 0 pin interrupt init_iptm_not_ip0 caution if the above macros are used, the contents of the window register are destroyed. if an embedded macro instruction is used immediately before the above macro instructions, an object error occurs when the source file is assembled and then loaded to the in-circuit emulator. to use an embedded macro instruction immediately before the above macro instructions, insert a comment statement between them. the status of the interrupt at reset is as follows: ? on power-on reset the interrupt is disabled. ? on execution of clock stop instruction the interrupt is disabled. ? on ce reset the interrupt is disabled. ? in halt status the interrupt permission flag holds the previous status.
m pd17016, 17017 76 10.2.3 vector address generator (vag) the vector address generator generates a branch address (vector address) of the program memory for the interrupt source acknowledged if a peripheral hardware interrupt has been acknowledged. table 10-3 shows the vector address of each interrupt source. table 10-3. vector address of each interrupt source interrupt source vector address int 0 pin 05h timer 03h
m pd17016, 17017 77 10.3 interrupt stack register 10.3.1 configuration and function of interrupt stack register figure 10-2 shows the configuration of the interrupt stack register and the system register whose contents are saved to the interrupt stack register. the interrupt stack register saves the contents of the following system registers when an interrupt is acknowledged. ? bank register (bank) ? index enable flag (ixe) when an interrupt is acknowledged and the contents of the above system registers are saved to the interrupt stack register, the contents of the above system registers are reset to 0. the interrupt stack register can save up to 4 levels of the contents of the above system registers. therefore, up to four levels of multiple interrupts can be executed. the contents of the interrupt stack register are restored to the system registers when an interrupt return instruction (reti) is executed. figure 10-2. configuration of interrupt stack register name bit 0h 1h 2h 3h interrupt stack register (intsk) bank stack status stack b 3 C C C C b 2 C C C C b 1 b 0 b 3 C C C C b 2 C C C C b 1 C C C C b 0 remark C: bit not saved
m pd17016, 17017 78 10.3.2 interrupt stack register operation figure 10-3 illustrates the operation of the interrupt stack register. if multiple interrupts exceeding 4 levels are acknowledged, the first saved contents are discarded and therefore, must be saved by program. figure 10-3. operation of interrupt stack register (a) if interrupt does not exceed level 4 undefined undefined undefined undefined v dd application a undefined undefined undefined interrupt a b a undefined undefined interrupt b a undefined undefined undefined reti undefined undefined undefined undefined reti (b) if interrupt exceeds level 4 a undefined undefined undefined interrupt a b a undefined undefined interrupt b c b a undefined interrupt c d c b a e d c b d c b b reti c b b b reti interrupt d interrupt e
m pd17016, 17017 79 10.4 stack pointer, address stack register, and program counter the address stack register saves the return address to which execution is to be returned from an interrupt processing routine. the stack pointer specifies the address of the address stack register. when an interrupt is acknowledged, therefore, the value of the stack pointer is decremented by one and the value of the program counter at that time is saved to the address stack register specified by the stack pointer. when the dedicated return instruction reti is executed after the processing of the interrupt processing routine has been executed, the contents of the address stack register specified by the stack pointer are restored to the program counter, and the value of the stack pointer is incremented by one. for further information, also refer to 3. address stack (ask) . 10.5 interrupt enable flip-flop (inte) the interrupt enable flip-flop enables all the interrupts. when this flip-flop is set, all the interrupts are enabled. when it is reset, all the interrupts are disabled. this flip-flop is set or reset by using dedicated instructions ei (to set) and di (to reset). the ei instruction sets this flip-flop when the instruction next to the ei instruction is executed, and the di instruction resets the flip-flop while the di instruction is executed. when an interrupt is acknowledged, this flip-flop is automatically reset. nothing is affected even if the di instruction is executed in the di state, or if the ei instruction is executed in the ei state. this flip-flop is reset on power-on reset, ce reset, and on execution of the clock stop instruction.
m pd17016, 17017 80 10.6 acknowledging interrupts 10.6.1 acknowledging interrupts and priority an interrupt is acknowledged in the following procedure: (1) each peripheral hardware unit outputs an interrupt request signal to the corresponding interrupt control block if a given interrupt condition is satisfied (e.g., if a rising signal is input to the int 0 pin). (2) when the interrupt control block has received the interrupt request signal from the peripheral hardware unit, it sets the corresponding interrupt request flag (e.g., irq0 flag if the peripheral unit is the int 0 pin) to 1. (3) if the interrupt permission flag corresponding to the interrupt request flag (e.g., ip0 flag for irq0 flag) is set to 1 when the interrupt request flag is set to 1, the interrupt control block outputs 1. (4) the signal output by the interrupt control block is anded with the output of the interrupt enable flip-flop, and an interrupt acknowledge signal is output. this interrupt enable flip-flop is set to 1 by the ei instruction and reset to 0 by the di instruction. if the interrupt control block outputs 1 while the interrupt enable flip-flop is 1, the interrupt is acknowledged. as shown in figure 10-1, the interrupt acknowledge signal is input to each interrupt control block when the interrupt has been acknowledged. the interrupt request flag is reset to 0 by the signal input to the interrupt control block, and a vector address corresponding to the interrupt is output. if more than one interrupt block outputs 1 at this time, the interrupt acknowledge signal is not transferred to the next stage. if more than one interrupt request is issued at the same time, therefore, the interrupts are acknowledged in the following priority. int 0 pin > timer the interrupt of an interrupt source is not acknowledged unless the corresponding interrupt permission flag is set to 1. if the interrupt permission flag is reset to 0, therefore, an interrupt with a high hardware priority can be disabled.
m pd17016, 17017 81 10.6.2 timing chart for acknowledging interrupt figure 10-4 shows the timing chart illustrating acknowledging interrupts. (1) in this figure illustrates how one interrupt is acknowledged. (a) in (1) shows the case where the interrupt request flag is lastly set to 1, and (b) in (1) shows the case where the interrupt permission flag is lastly set to 1. in either case, the interrupt is acknowledged when all the interrupt request flag, interrupt enable flip-flop, and interrupt permission flag are set to 1. if the last flag or flip-flop that was set to 1 satisfies the first instruction cycle of the movt dbf, @ar instruction or a given skip condition, the interrupt is acknowledged after the second instruction cycle of the movt dbf, @ar instruction or the instruction that is skipped (nop) has been executed. the interrupt enable flip-flop is set in the instruction cycle next to the one in which the ei instruction is executed. (2) in figure 10-4 illustrates how more than one interrupt is used. in this case, the interrupts are sequentially acknowledged according to the hardware priority if all the interrupt permission flags are set. the hardware priority can be changed by manipulating the interrupt permission flag by program. interrupt cycle shown in figure 10-4 is a special cycle in which the interrupt request flag is reset, a vector address is specified, and the contents of the program counter are saved after an interrupt has been acknowl- edged, and lasts for 4.44 m s, which is equivalent to the execution time of one instruction. for further information, refer to 10.7 operations after interrupt has been acknowledged .
m pd17016, 17017 82 figure 10-4. timing chart of acknowledging interrupt (1/3) (1) when one interrupt (e.g., rising of int 0 pin) is used (a) if interrupt is not masked by interrupt permission flag (ip ) <1> if movt instruction or normal instruction that satisfies skip condition is not executed when interrupt is acknowledged instruction number of steps in macro ei normal instruction interrupt cycle set1_ip0 note <3> <4> inte int 0 pin irq0 flag ip0 flag instruction cycle: 4.44 s interrupt enable period interrupt acknowledged interrupt processing routine m note software macro set1_ip0 consists of four instructions. <2> if movt instruction or instruction satisfying skip condition is executed when interrupt is acknowledged instruction number of steps in macro ei interrupt cycle set1_ip0 note <3> <4> inte int 0 pin irq0 flag ip0 flag interrupt acknowledged movt dbf,@ar skip instruction interrupt enable period interrupt processing routine note software macro set1_ip0 consists of four instructions.
m pd17016, 17017 83 figure 10-4. timing chart of acknowledging interrupt (2/3) (b) if interrupt is kept pending by interrupt permission flag instruction number of steps in macro ei set1_ip0 note <2> <3> int 0 pin irq0 flag ip0 flag <4> inte interrupt cycle interrupt acknowledged interrupt processing routine interrupt pending period note software macro set1_ip0 consists of four instructions.
m pd17016, 17017 84 figure 10-4. timing chart of acknowledging interrupt (3/3) (2) when two interrupts (int 0 pin and timer) are used (a) hardware priority int 0 pin interrupt pending period int 0 pin interrupt acknowledged int 0 pin interrupt processing timer interrupt pending period timer interrupt processing instruction number of steps in macro ei set2_iptm_ip0 note <2> <3> inte int 0 pin irq0 flag ip0 flag iptm flag irqtm flag timer interrupt ei interrupt cycle timer interrupt acknowledged interrupt cycle note software macro set2_iptm_ip0 consists of three instructions. (b) software priority timer interrupt pending period timer interrupt acknowledged timer interrupt processing int 0 pin interrupt pending period int 0 pin interrupt processing int 0 interrupt acknowledged instruction number of steps in macro ei set1_iptm note <3> <4> inte int 0 pin irq0 flag ip0 flag set1_ip0 note <3> <4> ei timer interrupt irqtm flag iptm flag interrupt cycle interrupt cycle note software macro set1_iptm, set1_ip0 consists of four instructions.
m pd17016, 17017 85 10.7 operation after interrupt has been acknowledged when an interrupt has been acknowledged, the following processing is sequentially executed. (1) the interrupt enable flip-flop and the interrupt request flag corresponding to the acknowledged interrupt are reset to 0, disabling the interrupts. (2) the contents of the stack pointer are decremented by one. (3) the contents of the program counter are saved to the address stack register specified by the stack pointer. the contents saved at this time are the next program memory address that is used after the interrupt has been acknowledged. for example, if a branch instruction is executed, the contents saved are the branch destination address; if a subroutine call instruction is executed, they are the called address. because the interrupt is acknowledged after the next instruction is executed as a nop instruction if a skip condition is satisfied by a skip instruction, the saved contents are the skipped address. (4) the low-order 2 bits of the bank register (bank) and the index enable flag (ixe) are saved to the interrupt stack. (5) the contents of the vector address generator corresponding to the acknowledged interrupt are transferred to the program counter. in other words, execution branches to an interrupt processing routine. the processing (1) through (5) above is executed in one special instruction cycle (4.44 m s) in which the normal instruction is not executed. this instruction cycle is called an interrupt cycle. in other words, one instruction cycle time is necessary since an interrupt has been acknowledged until execution branches to the corresponding vector address. 10.8 restoring from interrupt processing routine to restore execution from an interrupt processing routine to the processing that was being performed when the interrupt occurred, a dedicated instruction, reti, is used. when the reti instruction is executed, the following processing is sequentially executed. (1) the contents of the address stack register specified by the stack pointer are saved to the program counter. (2) the contents of the interrupt stack are restored to the low-order 2 bits of the bank register (bank) and index enable flag (ixe). (3) the contents of the stack pointer are incremented by one. the processing (1) through (3) above is executed in one instruction cycle in which the reti instruction is executed. the difference between the reti instruction and subroutine return instructions ret and retsk is only the restoring operation of the bank register and index enable flag in (2) above.
m pd17016, 17017 86 10.9 external (int 0 pin) interrupt 10.9.1 outline of external interrupt figure 10-5 outlines the external interrupt. as shown in the figure, the external interrupt issues an interrupt request at the rising edge of the signal input to the int 0 pin. the int 0 pin is a schmitt trigger input pin to prevent malfunctioning due to noise, and does not accept a pulse less than 1 m s wide. figure 10-5. outline of external interrupt rising edge detection detects pin status software macro skt1_int0 skf1_int0 int 0 pin interrupt control block irq0 flag schmitt trigger 10.9.2 edge detection block the edge detection block detects the rising edge that issues the interrupt request of the int 0 pin.
m pd17016, 17017 87 10.9.3 pin status detection function the level of the signal input to the int 0 pin can be detected by using software macros. therefore, the int 0 pin can be used as a 1-bit general-purpose input port when it is not used as an interrupt input pin. table 10-4 shows the software macros. these macros are defined in the device file and can be used by includeing the file supplied with the device file (d17016.inc for the m pd17016 and d17017.inc for the m pd17017) on the source program. table 10-4. software macros detecting int 0 pin level function macro format skips next instruction if high level is input to int 0 pin skt1_int0 skips next instruction if low level is input to int 0 pin skf1_int0 caution if the above macros are used, the contents of the window register are destroyed. if an embedded macro instruction is used immediately before the above macro instructions, an object error occurs when the source file is assembled and then loaded to the in-circuit emulator. to use an embedded macro instruction immediately before the above macro instructions, insert a comment statement between them. 10.10 internal interrupt the timer interrupt is used as the internal interrupt and can issue an interrupt request at fixed time intervals (refer to 11. timer function ).
m pd17016, 17017 88 10.11 notes on using interrupt other interrupts are not acknowledged while a software macro that resets an interrupt request is being executed. example 1. processing a clr1_irqtm interrupt request of int 0 pin is not acknowledged nor kept pending even if it is issued during this period. processing b example 2. processing a clr1_irq0 timer interrupt request is not acknowledged nor kept pending even if it is issued during this period. processing b
m pd17016, 17017 89 11. timer function the timer function is used for time management in developing a program. 11.1 configuration of timer figure 11-1 shows the configuration of the timer block. as shown in the figure, the timer consists of a timer carry block and a timer interrupt block. the clock generation circuit that sets the time of each timer divides the system clock by using clock select blocks a and b, and the timer mode select register (rf address 09h) of the control registers. the following subsections 11.1.1 and 11.1.2 respectively explain the configuration of the timer carry block and that of the timer interrupt block. because the clock of each timer is created by dividing the system clock (4.5 mhz), if the frequency of the crystal resonator is not 4.5 mhz, the clock of each timer varies accordingly. 11.1.1 configuration of timer carry block the timer carry block consists of clock select block a and timer carry ff block. 11.1.2 configuration of timer interrupt block the timer interrupt block consists of clock select block b and interrupt control block. figure 11-1. configuration of timer block ? timer carry block control register clock select a timer carry ff 4.5 mhz ? timer interrupt block control register clock select b 4.5 mhz interrupt control interrupt request signal
m pd17016, 17017 90 11.2 functional outline of timer the timer can be used in two ways: by detecting the carry ff of the timer carry and by using the interrupt of the timer. the following subsections 11.2.1 and 11.2.2 respectively outline the functions of the timer carry and timer interrupt. 11.2.1 functional outline of timer carry the timer carry manages time by detecting by program the status of the timer carry ff that is set at fixed intervals. refer to 11.3 timer carry . 11.2.2 functional outline of timer interrupt the timer interrupt manages time by issuing an interrupt request at fixed time intervals. refer to 11.4 timer interrupt . 11.3 timer carry 11.3.1 configuration of timer carry figure 11-2 shows the configuration of the timer carry. as shown in the figure, the timer carry consists of a divider, selector, and timer carry ff block. figure 11-2. configuration of timer carry name address bit flag symbol control register timer mode select timer carry ff judge 09h 17h b 3 b 2 b 1 b 0 b 3 0 b 2\ 0 b 1 0 b 0 timer carry ff divider 4.5 mhz 250 ms 100 ms 5 ms 1 ms selector b t m 1 c k 1 b t m 1 c k 0 b t m 0 c k 1 b t m 0 c k 0 b t m 0 c y
m pd17016, 17017 91 11.3.2 function of timer carry the timer carry is set to 1 at the rising edge of the timer carry ff setting pulse that is set by the low-order 2 bits (btm0ck1 and btm0ck0 flags) of the timer mode select register. the content of the timer carry ff corresponds to the least significant bit (btm0cy flag) of the timer carry ff judge register (rf address 17h) on a one-to-one basis. if the timer carry ff is set to 1, therefore, the btm0cy flag is also set to 1. the btm0cy flag is reset to 0 when data is written to the window register by the peek instruction (read & reset). when the btm0cy flag is reset to 0, the timer carry ff is also reset to 0. therefore, a timer that is set via the timer mode select register can be used by reading the contents of the btm0cy flag by program. when using the timer carry, note the following. caution the timer carry is disabled from being set on application of the supply voltage v dd (on power- on reset), and is not set to 1 until the content of the btm0cy flag is once read by the peek instruction. this means that 0 is always read from the btm0cy flag immediately after power-on reset, and that the flag is set to 1 at time intervals set by the timer mode select register. the timer carry also controls the timing of the reset operation by the ce pin (ce reset). if the ce pin goes high, ce reset is effected in synchronization with the timing that sets the timer carry ff to 1. therefore, a power failure can be detected by reading the content of the btm0cy flag at system reset (power- on reset and ce reset). for details, refer to 11.3.7 notes on using timer carry . because the btm0cy flag is a read-only flag, the device operation is not affected in any way even if data is written to this flag by using the poke instruction. however, an error occurs if the 17k series assembler is used. for details, refer to 8.4 notes on using register file .
m pd17016, 17017 92 11.3.3 configuration and function of timer mode select register the timer mode select register sets the time interval of the timer carry and the timer interrupt of the internal timer. these two time intervals can be set independently. figure 11-3 shows the waveform of a timer time setting pulse. name flag symbol b 3 b 2 b 1 b 0 address 09h read/ write r/w 0 0 1 1 0 1 0 1 sets time interval at which timer carry is set 100 ms 250 ms 5 ms 1 ms power-on clock stop ce reset 0 0 0 0 0 0 0 0 timer mode select register sets time interval at which timer interrupt is set note 100 ms 250 ms 5 ms 1 ms 0 0 1 1 0 1 0 1 holds status b t m 1 c k 1 b t m 1 c k 0 b t m 0 c k 1 b t m 0 c k 0 on reset note for the details on the timer interrupt, refer to 11.4 timer interrupt .
m pd17016, 17017 93 figure 11-3. waveform of timer time setting pulse 1 khz 200 hz 0.33 ms 0.67 ms 1 ms 2 ms 3 ms 5 ms 10 hz 4 hz 50 ms 50 ms 100 ms 100 ms 150 ms 250 ms
m pd17016, 17017 94 11.3.4 configuration and function of timer carry ff judge register the timer carry ff judge register detects the status of the timer carry ff of the internal timer. the configuration and function of this register are illustrated below. name flag symbol b 3 0 b 2 0 b 1 0 b 0 address 17h read/ write r & reset 0 1 detects status of timer carry ff timer carry ff is not set timer carry ff is set power-on clock stop ce reset 0000 1 1 timer carry ff judge register fixed to "0" b t m 0 c y on reset the btm0cy flag is set to 1 at time intervals set by the timer mode select register. the btm0cy flag is detected by the peek instruction via the window register. if the btm0cy flag is set to 1 at this time, the value of the flag is transferred to the window register, and then the btm0cy flag is reset to 0 (read & reset). the btm0cy flag is 0 on power-on reset, but 1 on ce reset (including ce reset that is executed in the clock stop status); therefore, it can be used as a power failure detection flag. the btm0cy flag is not set to 1 until it is read once by the peek instruction after power-on reset. once the peek instruction has been executed, it is set to 1 at the time interval set by the timer mode select register.
m pd17016, 17017 95 11.3.5 example of using timer with btm0cy flag here is an example program. example m1 mem 0.10h ; 1-second counter initflg not btm0ck1, btm0ck0 ; embedded macro ; sets set time of timer carry ff to 250 ms loop: skt1 btm0cy ; embedded macro ; tests btm0cy flag; if 0, branches to next br next add m1, #0100b ; adds 4 to data memory m1 skt1 cy ; embedded macro ; tests cy flag and, br next ; if 0, branches to next ; if 1, executes processing a processing a next processing b ; executes processing b and branches to loop br loop this program executes processing a every 1 second. in developing a program, the following point must be noted. caution keep the time interval at which the btm0cy flag is detected shorter than the time interval at which the timer carry ff is set to 1. this is because, in the above example, if the execution time of processing b is longer than 250 ms, setting of the timer carry ff is not detected. figure 11-4. detection of btm0cy flag and timer carry ff h l 1 0 timer carry ff setting pulse btm0cy flag <1> <2> skt1 btm0cy skt1 btm0cy skt1 btm0cy processing b processing b' because the execution time of processing b' is long, after the btm0cy flag set in <2> has been detected, the status of btm0cy fla g that is set in <3> is not detected. <3> <4> <5>
m pd17016, 17017 96 11.3.6 error of timer caused by btm0cy flag the error of the timer caused by the btm0cy flag includes an error caused by the detection time of the btm0cy flag and an error that occurs when the set time of the timer carry ff is changed. (1) error caused by detection time of btm0cy flag as explained in 11.3.5, the time interval at which the btm0cy flag is detected must be shorter than the time interval at which the timer carry ff is set to 1. where the time interval at which the btm0cy flag is detected is t check and the time interval at which the timer carry ff is set is t set (250, 100, 5, or 1 ms), the following relation must be satisfied. t check < t set the error of the timer when the btm0cy flag is detected as shown in figure 11-5 is as follows. 0 < error < t check figure 11-5. error caused by detection time of btm0cy flag h l 1 0 t set t check1 t check2 t check3 skt1 btm0cy <1> skt1 btm0cy <2> skt1 btm0cy <3> skt1 btm0cy <4> timer carry ff setting pulse btm0cy flag as shown in figure 11-5, the timer is updated when the btm0cy flag is detected in <2> because it is 1. when the flag is 0 when it is detected in <3> next. therefore, the timer is not updated until the flag is detected again in <4>. at this time, the time of the timer is prolonged by the time of t check3 .
m pd17016, 17017 97 (2) error when changing set time of timer carry ff the set time of the timer carry ff is set by the btm0ck1 and btm0ck0 flags of the timer mode select register. four types of timer time setting pulses, 1 khz, 200 hz, 10 hz, and 4 hz, can be selected as shown in figures 11-2 and 11-3. these four pulses operate independently. if the timer time setting pulse is changed by using the btm0ck1 and btm0ck0 flags, an error occurs as shown in the following example. example ; <1> initflg btm0ck1, not bmt0ck0 ; embedded macro ; sets timer carry ff setting pulse to ; 200 hz (5 ms) processing a ; <2> set2 btm0ck1, btm0ck0 ; embedded macro ; sets timer carry ff setting pulse to ; 1 khz (1 ms) processing a ; <3> initflg btm0ck1,not btm0ck0 ; embedded macro ; sets timer carry ff setting pulse to ; 200 hz (5 ms) the timer carry ff setting pulse is changed as follows at this time. instruction of <2> instruction of <3> skt1 btm0cy <1> h l h l h l 0 1 internal pulse 200hz internal pulse 1 khz timer carry ff setting pulse btm0cy flag when the set time of the timer carry ff is changed as shown above, the btm0cy flag holds the previous status (<2> in the figure) if the changed pulse falls, but is set to 1 (<3> in the figure) if the pulse rises.
m pd17016, 17017 98 in the previous example, the timer time setting pulse is changed between 200 hz (5 ms) and 1 khz (1 ms). the same applies when the pulse is changed between 4 hz (250 ms) and 10 hz (100 ms). therefore, an error until the btm0cy flag is set first when the timer carry ff setting time is changed as shown in figure 11-6 is as follows. Ct set < error < t check where, t set : new timer carry ff setting time t check : time to detect btm0cy flag the internal pulses of 4 hz, 10 hz, 200 hz, and 1 khz have a phase difference. this phase difference is included in the above error because it is shorter than the time of the new pulse. for the phase difference of each pulse, refer to 11.4.5 notes on using timer interrupt . figure 11-6. error when timer carry ff setting time is changed from a to b <1> error of ? set h l h l h l 1 0 t set a a=0 skt1 btm0cy original timer time actual timer time time changed error is ? set because btm0cy flag is ??if it is detected immediately after timer time has been chan g ed. <2> error of t check t set a t check actual timer time original timer time time changed error is t check because btm0cy flag is reset once if timer time is changed immediately after btm0cy fla g has been detected. internal pulse a internal pulse b timer carry ff setting pulse btm0cy flag a=0
m pd17016, 17017 99 11.3.7 notes on using timer carry the timer carry is also used as a reset synchronization signal when reset is effected by the ce pin (ce reset), not only for the timer function. the ce reset is effected if the timer carry ff setting pulse rises the next time after the ce pin has gone high. at this time, the following points must be noted. (1) the sum of the timer updating processing time and the btm0cy flag detection time must be shorter than the timer carry ff setting time. (2) if a program is created in which the timer always operates at a fixed interval regardless of ce reset after application of the supply voltage (power-on reset), correction must be made each time ce reset is effected. (3) detection of the btm0cy flag takes precedence over the reset synchronization signal on ce reset. if these two coincide, therefore, ce reset is delayed once. (1) through (3) above are explained in more detail in the following (a) through (c).
m pd17016, 17017 100 (a) timer updating processing time and detection time interval of btm0cy flag as explained in 11.3.6, the time interval t set at which the btm0cy flag is detected must be shorter than the time interval at which the timer carry ff is set. if the updating processing time of the timer is long even if the time interval to detect the btm0cy flag is short, the timer processing may not be executed normally if ce reset is effected. therefore, the following condition must be satisfied. t check + t timer < t set where, t check : time interval to detect btm0cy flag t timer : timer updating processing time t set : time to set timer carry ff here is an example. example example of timer updating processing and btm0cy flag detection time interval start: ; program address 0000h clr2 btm0ck1, btm0ck0 ; embedded macro ; sets set time of timer carry ff to 100 ms timer: ; <1> skt1 btm0cy ; embedded macro br aaa ; tests btm0cy flag; if 0, branches to aaa timer update br timer aaa: processing a br timer the timing chart of the above program is shown below. h l h l 1 0 btm0cy detection interval t check timer updating processing t timer skt1 btm0cy skt1 btm0cy ce reset if this processing time is long, ce reset is effected while processing is in progress. timer carry ff setting pulse ce pin btm0cy flag
m pd17016, 17017 101 (b) correction of timer carry on ce reset an example of correcting the timer at ce reset is shown below. as shown in this example, the timer must be corrected on ce reset if the timer carry is used to detect a power failure and the timer carry is also used as a watch timer. the timer carry is reset to 0 on first power application (power-on reset), and afterward, is disabled from being set until the btm0cy flag is read once by the peek instruction. if the ce pin goes high, ce reset is effected in synchronization with the rising edge of the timer carry ff setting pulse. at this time, the btm0cy flag is set to 1 and the program is started. therefore, it is judged that power-on reset has been effected if the btm0cy flag is 0 and that ce reset has been effected if the btm0cy flag is 1, by detecting the status of the btm0cy flag on system reset (power-on reset or ce reset). a power failure can be detected in this way. at this time, the watch timer must continue operating even on ce reset. however, because the btm0cy flag is reset to 0 when the flag is read to detect a power failure, the set 1 status of the btm0cy flag is overlooked once. therefore, the watch timer must be updated if it is judged by means of power failure detection that ce reset has been effected. for the details on power failure detection, refer to 13.6 power failure detection . example example of correcting timer on ce reset (to detect power failure and update watch by timer carry) start: ; program address 0000h processing a ; <1> skt1 btm0cy ; embedded macro ; tests btm0cy flag; br initial ; if 0, branches to initial (power failure detection) backup: ; <2> updates watch ; updates watch because back up (ce reset) is by 100 ms ; performed loop: ; <3> processing b ; while performing processing b, skf1 btm0cy ; tests btm0cy flag and updates watch br backup br loop initial: clr2 btm0ck1, btm0ck0 ; embedded macro ; because power failure (power-on reset) occurs, sets ; set time of timer carry ff to 100 ms, and executes ; processing c processing c br loop figure 11-7 shows the timing chart of the above program.
m pd17016, 17017 102 figure 11-7. timing chart ac <1> <3> <3> <3> <3> bb bbb <3> <3> bb b <3> <3> <3> <3> bb a <1> <3> <3> bbb updates watch updates watch updates watch updates watch updates watch ce reset program starts from address 0. watch is updated because btm0cy flag is set (1) btm0cy flag detection power-on reset program starts from address 0 applocation of supply voltage point a point b point c point d point e 5 v 0 v h l h l h l 1 0 v dd ce internal pulse 10 hz timer carry ff setting pulse btm0cy flag program processing program instruction as shown in figure 11-7, the program is started from address 0000h at the rising edge of the internal 10-mhz pulse when supply voltage v dd is applied first. when the btm0cy flag is detected at point a, the btm0cy flag is reset to 0 because power has been just applied, and it is judged that a power failure (power-on reset) has occurred. therefore, processing c is executed and the timer carry ff setting pulse is set to 100 ms. because the contents of the btm0cy flag are read once at point a, the btm0cy flag is set to 1 every 100 ms. next, the program counts up the watch while executing processing b even if the ce pin goes low at point b and high at point c, unless the clock stop instruction is executed. because the ce pin goes high at point c, ce reset is effected at point d where the pulse for setting the next timer carry ff rises and the program is started from address 0000h. because the btm0cy flag is set to 1 when it is detected at point e at this time, it is judged that back up (ce reset) has been performed. as is evident from the figure, the watch is delayed by 100 ms each time ce reset is effected unless the watch is updated by 100 ms at point e. if processing a takes longer than 100 ms when a power failure is detected at point e, setting of the btm0cy flag is overlooked two times; therefore, processing a must be completed in less than 100 ms. the same applies when the timer carry ff setting pulse is set to 250, 5, or 1 ms. therefore, the btm0cy flag must be detected to detect a power failure within the timer carry ff setting time after the program has started from address 0000h.
m pd17016, 17017 103 (c) if btm0cy flag is detected at same time as ce reset as explained in (b), ce reset is effected if the btm0cy flag is set to 1. if an instruction that reads the btm0cy flag happens to be executed at the same time as ce reset, execution of the instruction that reads the btm0cy flag takes precedence. therefore, if the next setting of the btm0cy flag (rising of the timer carry ff setting pulse) after the ce pin has gone high is performed at the same time as the instruction that reads the btm0cy flag, ce reset is effected when the btm0cy flag is set next. this operation is illustrated in figure 11-8. figure 11-8. operation when ce reset is executed at same time as instruction that reads btm0cy flag h l h l 1 0 ce pin timer carry ff setting pulse btm0cy flag skt1 btm0cy ce reset skt1 btm0cy h l 1 0 timer carry ff setting pulse btm0cy flag instruction embedded macro peek wr,. mf. btm0cy shr4 skt wr, #. df. btm0cy and 000 fh skt 1 btm0cy (peek ) (skt ) 4.44 s if btm0cy flag is read during this period, ce reset is delayed once. program is supposed to start from address 0000h at this time, but ce reset is not effected because program that reads btm0cy takes precedence. m therefore, a program that periodically detects the btm0cy flag never executes a ce reset if the detection interval of the btm0cy flag is the same as the setting time of the tmcy flag. this must be prevented as follows. because one instruction cycle is 4.44 m s (1/225 khz), a program, for example, that detects the btm0cy flag once every 255 instructions reads the btm0cy flag every 1 ms = 4.44 m s 225. once detection and setting of the btm0cy flag coincide, ce reset is never effected no matter which of 1, 5, 100, or 250 ms of the timer time setting pulse is selected. therefore, do not develop a program that has a cycle satisfying the following condition . t set 225 = n (n: natural number) x where, t set : setting time of btm0cy flag x : period x number of steps of instruction that reads btm0cy flag an example of a program that satisfies this condition is shown below. do not develop such a program.
m pd17016, 17017 104 example processing a set2 btm0ck1, btm0ck0 ; embedded macro ; timer carry ff setting pulse is set to 1 ms loop: ; <1> skt1 btm0cy ; embedded macro br bbb aaa: 221 steps br loop bbb: 221 steps br loop in this example, the instruction <1> that reads the btm0cy flag is repeatedly executed every 225 instructions. if the btm0cy flag is set at the timing of the instruction <1>, therefore, ce reset is not effected.
m pd17016, 17017 105 11.4 timer interrupt 11.4.1 configuration of timer interrupt figure 11-9 shows the configuration of the timer interrupt. as shown in the figure, the timer interrupt consists of a divider, selector, and interrupt control flag. figure 11-9. configuration of timer interrupt name address bit flag symbol control register timer mode select 09h b 3 b 2 b 1 b 0 irqtm flag divider 4.5 mhz 250 ms 100 ms 5 ms 1 ms selector iptm flag issuance of interrupt request b t m 0 c k 0 b t m 0 c k 1 b t m 1 c k 0 b t m 1 c k 1 remark the interrupt permission flag (iptm) is set by a software macro. the interrupt request flag (irqtm) can be reset by software. for details, refer to 10. interrupt .
m pd17016, 17017 106 11.4.2 function of timer interrupt the timer interrupt request is issued at the falling edge of a timer interrupt pulse set by the high-order 2 bits (btm1ck1 and btm1ck0 flags) of the timer mode select register (refer to 11.3.3 ). the timer interrupt request corresponds to the irqtm flag on a one-to-one basis. when the timer interrupt request is issued, the irqtm flag is set to 1. in other words, the irqtm flag is set to 1 if the timer interrupt pulse falls. so that the timer interrupt is acknowledged, the ei instruction that enables all the interrupts must be executed and the timer interrupt must be enabled, in addition to issuance of the interrupt request as explained in 10. interrupt . the timer interrupt is enabled by setting the iptm flag to 1. therefore, the timer interrupt is acknowledged if the irqtm flag is set to 1 when the ei instruction is executed and the iptm flag is set to 1. the iptm flag is set by a software macro. for the macro that enables or disables an interrupt, refer to table 10-2. software macros enabling/disabling interrupts . the irqtm flag cannot be set by software. when the timer interrupt is acknowledged, the program execution branches to program memory address 0003h. the irqtm flag is reset to 0 as soon as the interrupt has been acknowledged. figure 11-10 shows the relation between the timer interrupt pulse and irqtm flag. figure 11-10. relation between timer interrupt pulse and irqtm flag h l 1 0 1 0 ei di timer interrupt pulse irqtm iptm inte ff interrupt pending period interrupt enable period irqtm flag is set at falling edge of timer interrupt pulse <1> interrupt is not acknowledged even if ei instruction is executed because iptm flag is not set timer interrupt is acknowledged as soon as iptm flag is set, and interrupt processing is executed acknowledging timer interrupt and interrupt processing a point to be noted is that, as shown in point <1> in the above figure, the timer interrupt is acknowledged when the ei instruction is executed next and the iptm flag is set once the irqtm flag has been set when the timer interrupt is disabled by the di instruction or iptm flag. in this case, the interrupt request can be cleared by executing a software macro that resets the interrupt request (refer to table 10-1. software macros that reset interrupt requests ). one level of the stack is used when the timer interrupt is acknowledged. at this time, the contents of the register bank (bank: address 79h) and the content of the index enable flag (ixe: bit 0 of address 7fh) are automatically saved. to return from the interrupt processing routine, use a dedicated instruction reti. for details, refer to 3. address stack (ask) and 10. interrupt . the following subsections 11.4.3 and 11.4.4 explain an example of using the timer interrupt and an error of the timer interrupt. for the relation between the timer interrupt and the other interrupt (int 0 pin), refer to 10. interrupt .
m pd17016, 17017 107 11.4.3 example of using timer with timer interrupt example m1 mem 0.10h ; 80-ms counter timer dat 0003h ; symbol definition of timer interrupt vector address br start ; branches to start org timer ; program address (0003h) add m1, #0001b ; adds 1 to m1 skt1 cy ; tests cy flag br ei_reti ; return if carry does not occur processing a ei_reti: ei reti start: initflg btm1ck1, not btm1ck0 ; embedded macro ; sets timer interrupt pulse to 5 ms mov m1, #0000b ; clears contents of m1 set1_iptm ; enables timer interrupt (software macro) ei ; enables all interrupts loop: processing b br loop the above program executes processing a every 80 ms. the points to be noted at this time are that the di status is automatically set when the interrupt is acknowledged, and that the irqtm flag is set to 1 even in the di status. if processing a takes longer than 5 ms, therefore, the interrupt is acknowledged even if the reti instruction is executed. consequently, processing b is not executed.
m pd17016, 17017 108 11.4.4 error of timer interrupt as explained in 11.4.2, the timer interrupt is acknowledged each time the timer interrupt pulse falls if the ei instruction is executed and the timer interrupt is enabled. therefore, an error of the timer when the timer interrupt is used occurs only in the following cases (1) through (3). (1) when the first interrupt is acknowledged with the timer interrupt enabled (2) when the first interrupt is acknowledged with the time of the timer interrupt pulse changed (3) if the software macro that resets the timer interrupt request is executed at the same time as the falling of the timer interrupt pulse (the interrupt is not acknowledged) figure 11-11 shows the errors that may occur in each of the above cases. figure 11-11. error of timer interrupt (1/2) (a) when timer interrupt is enabled h l 1 0 1 0 ei di timer interrupt pulse irqtm iptm inte ff ei interrupt pending t set ei ei <1><2> <3> set1_iptm interrupt acknowled g ed interrupt acknowledged interrupt acknowledged at point <1> in the above figure, the timer interrupt is acknowledged immediately if the interrupt is enabled by setting the iptm flag. at this time, the error is -t set . if the interrupt is enabled by the ei instruction at point <2>, the interrupt occurs at the falling edge of the timer interrupt pulse at point <3>. at this time, the error is Ct set < error < 0.
m pd17016, 17017 109 figure 11-11. error of timer interrupt (2/2) (b) if timer interrupt pulse is changed h l h l h l 1 0 1 0 ei di internal pulse a internal pulse b timer interrupt pulse irqtm iptm inte ff ei interrupt acknowledged ei ei ei <2>interrupt acknowledged <3> timer interrupt pulse changed interrupt acknowledged ei <1> timer interrupt pulse chan g ed because the timer interrupt pulse does not fall even if the timer interrupt pulse is changed to b at point <1>, the interrupt is acknowledged at the next point <2>. if the timer interrupt pulse is changed to a at point <3>, the timer interrupt pulse falls, and the interrupt is immediately acknowledged.
m pd17016, 17017 110 11.4.5 notes on using timer interrupt when developing a program in which the timer always operates after the supply voltage v dd has been once applied (power-on reset) by using the timer interrupt, such as a watch program, the timer interrupt processing must be completed within specific time. take the following program for example. example m1 mem 0.10h ; 1-ms counter timer dat 0003h ; symbol definition of interrupt vector address br start ; branches to start org timer ; program address (0003h) add m1, #0100b ; adds 0100b to contents of m1 skt1 cy ; watch processing if carry occurs br ei_reti ; return if carry does not occur ; <1> watch processing ei_reti: ei reti start: initflg not btm1ck1, btm1ck0, not btm0ck1, not btm0ck0 ; embedded macro ; sets timer interrupt time to 250 ms and timer carry ff ; setting time to 100 ms set1_iptm ; enables timer interrupt (software macro) ei ; enables all interrupts loop: processing a br loop in this example, watch processing <1> is executed every 1 second while processing a is executed. if the ce pin goes high, ce reset is effected in synchronization with the rising of the timer carry ff setting pulse, as shown in figure 11-12 (a). if the timer interrupt request (irqtm flag) is issued at the same time as setting of the timer carry ff, ce reset takes precedence. when ce reset is effected, the irqtm flag is automatically reset to 0. in other words, timer processing is not executed once if the ce reset is effected while the irqtm flag is set to 1.
m pd17016, 17017 111 to prevent this, a delay time is provided between rising of the timer carry ff setting pulse and falling of the timer interrupt pulse as shown in figure 11-12(b). in the above example, the timer interrupt is not overlooked even if the ce reset is effected if the watch processing is executed within 10 ms as shown in figure 11-12(b). because the timer carry ff and timer interrupt time setting pulse can be set to 4 hz (250 ms), 10 hz (100 ms), 200 hz (5 ms), or 1 khz (1 ms) independently, time differences shown in figure 11-13 and table 11-1 are provided. to validate the timer interrupt at ce reset, therefore, the processing of the timer interrupt must be completed within the delay time of the pulse as shown in figure 11-13. figure 11-12. timing chart (a) h l h l h l ce pin timer carry ff setting pulse timer interrupt pulse timer interrupt ce reset is effected at this point and timer interrupt is overlooked once because timer carr y ff settin g pulse rises. (b) h l h l h l timer interrupt timer interrupt delay time (10 ms in this case) ce reset because falling of timer interrupt pulse and rising of timer carry ff setting pulse are delayed for 10 ms, timer processing is executed normally even if ce reset is effected if timer interrupt processing is completed within 10 ms ce pin timer carry ff setting pulse timer interrupt pulse
m pd17016, 17017 112 figure 11-13. time difference between timer carry ff setting pulse and timer interrupt pulse 2 : 1 : 1 1 ms 1 ms btm0cy 1 ms int 5 ms btm0cy 5 ms int 10 ms 250 ms int 250 ms btm0cy 100 ms int 100 ms btm0cy dummy
m pd17016, 17017 113 table 11-1. time difference between rising edge of timer carry ff pulse and falling edge of timer interrupt pulse internal pulse minimum value of time difference (refer to figure below.) timer carry timer interrupt t 1 t 2 1 ms 1 ms 666 m s 333 m s 1 ms 5 ms 333 m s 666 m s 1 ms 100 ms 333 m s 666 m s 1 ms 250 ms 333 m s 666 m s 5 ms 1 ms 333 m s 666 m s 5 ms 5 ms 3 ms 2 ms 5 ms 100 ms 2 ms 3 ms 5 ms 250 ms 2 ms 3 ms 100 ms 1 ms 333 m s 666 m s 100 ms 5 ms 1 ms 4 ms 100 ms 100 ms 50 ms 50 ms 100 ms 250 ms 10 ms 40 ms 250 ms 1 ms 333 m s 666 m s 250 ms 5 ms 1 ms 4 ms 250 ms 100 ms 40 ms 10 ms 250 ms 250 ms 100 ms 150 ms t 2 t 1 h l h l timer carry ff setting pulse timer interrupt pulse
m pd17016, 17017 114 12. standby the standby function is used to reduce the current consumption of the device during back up. 12.1 configuration of standby block figure 12-1 shows the configuration of the standby block. as shown in the figure, the standby block is divided into two blocks: halt control block and clock stop control block. the halt control block consists of a halt control circuit, interrupt control block, timer carry, and key input pins p0d 0 /adc 2 through p0d 3 /adc 5 , and controls the operation of the cpu (program counter, instruction decoder, and alu block). the clock stop control block controls the 4.5-mhz crystal oscillation circuit, cpu, system register, and control registers, by using the clock stop control circuit. figure 12-1. configuration of standby block interrupt block timer carry halt control circuit halt h program counter (pc) instruction decoder alu system register control register clock stop control circuit stop s halt block clock stop block p0d 3 /adc 5 pin p0d 2 /adc 4 pin p0d 1 /adc 3 pin p0d 0 /adc 2 pin ce pin x out pin x in pin internal block cpu input latch
m pd17016, 17017 115 12.2 standby function the standby function reduces the current consumption of the device by stopping some or all the operations of the device. the standby function can be used in two modes: halt and clock stop. the halt mode is to reduce the current consumption of the device by executing a dedicated instruction halt h and stopping the operation of the cpu. the clock stop mode is to reduce the current consumption of the device by executing a dedicated instruction stop s and stopping the 4.5-mhz crystal oscillation circuit. in addition to the halt and clock stop modes, the operation mode of the device can be also set by the ce pin. the ce pin is used to control the operation of the pll frequency synthesizer and reset the device, and can be said to be a type of the standby function in that it controls the operation of the pll frequency synthesizer. the following section 12.3 explains how to set the operation mode of the device by using the ce pin. sections 12.4 and 12.5 respectively explain the halt and clock stop modes. 12.3 selecting device operation mode with ce pin the ce pin controls the following functions (1) through (3) by using the level and rising edge of an externally input signal. (1) controls operation of pll frequency synthesizer (2) enables or disables clock stop instruction (3) resets device 12.3.1 controlling operation of pll frequency synthesizer the pll frequency synthesizer can operate only when the ce pin is high. the pll frequency synthesizer is automatically disabled when the ce pin is low. at this time, the vcoh and vcol pins are internally pulled down, and the eo 0 and eo 1 pins are floated. the pll frequency synthesizer can be disabled by program at any time when the ce pin is high. 12.3.2 enabling and disabling clock stop instruction the clock stop instruction stop s is enabled only when the ce pin is low. the stop s instruction is executed as a no-operation (nop) instruction if it is executed when the ce pin is high. 12.3.3 resetting device the device can be reset (ce reset) by raising the ce pin. the device can also be reset through power application (power-on reset). for details, refer to 13. reset .
m pd17016, 17017 116 12.3.4 inputting signal to ce pin the ce pin does not accept a low or high level of less than 110 to 165 m s to prevent malfunctioning due to noise. the level of the signal input to the ce pin can be detected by using the ce flag of the ce pin level judge register (rf address 07h). figure 12-2 shows the relation between the input signal and ce flag. figure 12-2. relation between signal input to ce pin and ce flag 12.3.5 configuration and function of ce pin level judge register the ce pin level judge register detects the level of the signal input to the ce pin. the configuration and function of this register are illustrated below. the ce flag is not affected by a low or high level of less than 110 to 165 m s. h l 1 0 ce pin ce flag ce reset less than 110 to 165 s 110-165 s 110-165 s pll operation enabled stop s instruction disabled (nop) pll disabled stop s instruction enabled pll disabled stop s instruction enabled (nop) ce reset is executed in synchronization with next setting of timer carry ff mm less than 110 to 165 s m m name flag symbol b 3 0 b 2 0 b 1 0 b 0 c e address 07h read/ write r 0 1 detects level input to ce pin low level high level power-on clock stop ce reset 000C C C ce pin level judge register fixed to 0 C : determined depending on pin status on reset
m pd17016, 17017 117 12.4 halt function the halt function stops the operation clock of the cpu by executing the halt h instruction. when the halt h instruction is executed, the program stops at the halt h instruction, until the halt status is released later. therefore, the current consumption of the device can be reduced in the halt status by the operating current of the cpu. the halt status can be released by key input, timer carry, or interrupt. the releasing condition of the key input, timer carry, and interrupt is specified by the operand h of the halt h instruction. the halt h instruction is valid regardless of the input level of the ce pin. the following subsections 12.4.1 through 12.4.6 explain the halt status, halt release condition, and each halt release condition. 12.4.1 halt status all the operations of the cpu are stopped in the halt status. in other words, program execution is stopped at the halt h instruction. however, the peripheral hardware units continue the operations set before the halt h instruction is executed. for the operations of the peripheral hardware units, refer to 12.6 device operations in halt and clock stop status .
m pd17016, 17017 118 12.4.2 halt release condition figure 12-3 shows the halt release conditions. as shown in this figure, the halt release conditions are set by 4-bit data specified by operand h of the halt h instruction. the halt status is released when the condition specified as 1 by operand h is satisfied. when the halt status is released, the execution starts from the instruction next to the halt h instruction. if two or more release conditions are specified, and if any one of the specified conditions is satisfied, the halt condition is released. if the device is reset (power-on reset or ce reset), the halt status is released, and each reset operation is performed. if 0000b is set as the halt release condition h, no release condition is set. at this time, the halt status is released if the device is reset (power-on reset or ce reset). the following subsections 12.4.3 through 12.4.5 explains halt release conditions set by key input, timer carry, and interrupt. 12.4.6 shows an example when two or more release conditions are specified. figure 12-3. halt release condition operand bit b 3 b 2 b 1 b 0 sets halt release condition halt h (4 bits) releases if high level is input to p0d pin (p0d 3 /adc 5 -p0d 0 /adc 2 ) releases if timer carry ff is set to 1 undefined (fixed to 0) releases if interrupt (int 0 pin or timer) is acknowledged does not release even if condition is satisfied releases if condition is satisfied 0 1
m pd17016, 17017 119 12.4.3 releasing halt status by key input releasing the halt status by key input is specified by the halt 0001b instruction. if releasing the halt status by key input is specified, the halt status is released when a high level is input to any of the four pins p0d 0 /adc 2 through p0d 3 /adc 5 . the following paragraphs (1) through (4) explain the points to be noted when using a general-purpose output port for a key source signal, when multiplexing lcd segment signal output with key source signal output, and when using one of the p0d 0 /adc 2 through p0d 3 /adc 5 pins as an a/d converter pin. (1) notes on using general-purpose output port for key source signal the halt 0001b instruction is executed after a general-purpose output port for key source signal goes high. if an alternate switch such as switch a in the above figure is used at this time, a high level is always applied to the p0d 0 /adc 2 pin while switch a is closed, and the halt status is immediately released. therefore, care must be execised in using the alternate switch. when using a general-purpose output port for key source signal, reset the ksen flag of the lcd mode select register (rf address 10h) to 0. at this time, the p0d 0 /adc 2 through p0d 3 /adc 5 pins are automatically pulled down. latch p0d 3 /adc 5 p0d 2 /adc 4 p0d 1 /adc 3 p0d 0 /adc 2 general-purpose output port switch a
m pd17016, 17017 120 (2) notes on multiplexing lcd segment signal output and key source signal output execute the halt 0001b instruction after setting key source signal output data. at this time, the halt status is not released even if a high level of the lcd segment signal is input to the pin whose key source signal output data is 0. to multiple lcd segment signal output with key source signal output, set the ksen flag of the lcd mode select register to 1. the key source signal data (setting the pin that outputs a key source) is set by the key source data register (ksr: peripheral address 42h) via the data buffer. the internal key latch circuit when lcd segment signal output is multiplexed with key source signal output latches data only while the key source signal is output, and is disconnected from the external source while the lcd segment signal is output. the internal pull-down resistor is on only when the key source signal is output. latch p0d 3 /adc 5 p0d 2 /adc 4 p0d 1 /adc 3 p0d 0 /adc 2 lcd 15 /ks 15 lcd segment signal 220 s ke y source si g nal l h lcd segment signal output waveform m
m pd17016, 17017 121 (3) notes on using p0d 0 /adc 2 to p0d 3 /adc 5 pin as a/d converter pin when any of the p0d 0 /adc 2 through p0d 3 /adc 5 pins is used as an a/d converter pin, the selected pin (only one pin can be selected at one time) is disconnected from the input latch and is connected to the internal a/ d converter input. if a high level is input to the pin selected as an a/d converter pin at this time, the latch circuit holds the high level. if the halt 0001h instruction is executed in this status, the halt status is immediately released even if the instruction can be executed because the input latch is at high level. to prevent this, set the pin in the input port mode before executing the halt 0001h instruction, and set a low level for a/d converter input. (4) others the p0d 0 /adc 2 through p0d 3 /adc 5 pins can also be used as general-purpose input port pins with pull-down resistors. therefore, the halt status can also be controlled by using an external microcontroller as shown above. latch p0d 3 /adc 5 p0d 2 /adc 4 p0d 1 /adc 3 p0d 0 /adc 2 general-purpose output port or lcd segment signal output a/d input a/d input latch p0d 3 /adc 5 p0d 2 /adc 4 p0d 1 /adc 3 p0d 0 /adc 2 general-purpose output port or lcd segment signal output output port microcontroller, etc.
m pd17016, 17017 122 12.4.4 releasing halt status by timer carry releasing the halt status by the timer carry is set by the halt 0010b instruction. when the release of the halt status is set by the timer carry, the halt status is released as soon as the timer carry ff has been set to 1. the timer carry ff corresponds to the btm0cy flag of the timer carry ff judge register on a one-to-one basis, as explained in 11. timer function , and is set to 1 at fixed time intervals (1 ms, 5 ms, 100 ms, or 250 ms). therefore, the halt status can be released at fixed time intervals. example m1 mem 0.10h ; 1-second counter hlttmr dat 0010b ; symbol definition clr2 btm0ck1, btm0ck0 ; embedded macro ; sets timer carry ff setting time to 250 ms loop: halt hlttmr ; sets release condition by timer carry ff and halt status skt1 btm0cy ; embedded macro br loop ; branches to loop if btm0cy flag is not set add m1, #0100b ; adds 0100b to contents of m1 skt1 cy ; embedded macro br loop ; executes processing a if carry occurs processing a br loop in this example, the halt status is released every 250 ms and processing a is executed every 1 second. 12.4.5 releasing halt status by interrupt releasing the halt status by an interrupt is set by the halt 1000b instruction. if releasing the halt status by an interrupt is set, the halt status is released as soon as the interrupt has been acknowledged. two interrupt sources, int 0 pin and timer, are available as explained in 10. interrupt . therefore, the interrupt source to be used to release the halt status must be specified by program in advance. so that the interrupt is acknowledged, all the interrupts must be enabled (by the ei instruction), each interrupt is enabled (by setting the corresponding interrupt permission flag), in addition that the interrupt request must be issued from each interrupt source. even if an interrupt request is issued, if that interrupt is not enabled, the interrupt is not acknowledged and the halt status is not released. when the halt status has been released because the interrupt has been acknowledged, the program flow branches to the vector address of the interrupt. if the reti instruction is executed after the interrupt processing, the program flow returns to the instruction next to the halt instruction. here is an example.
m pd17016, 17017 123 example hltint dat 1000b ; symbol definition of halt condition inttm dat 0003h ; interrupt vector address symbol definition int0pin dat 0005h ; start: ; program address 0000h br main org inttm ; timer interrupt vector address (0003h) br inttimer org int0pin ; int 0 pin interrupt vector address (0005h) processing a ; interrupt processing by int 0 pin br ei_reti inttimer: processing b ; interrupt processing by timer ei_reti: ei reti main: set2_iptm_ip0 ; software macro set2 btm1ck1, btm1ck0 ; embedded macro ; sets time interval of timer interrupt to 1 ms loop: processing c ; main routine processing ei ; enables all interrupts halt hltint ; specifies releasing halt by interrupt ; <1> br loop in this example, the halt status is released when the timer interrupt is acknowledged, and processing b is executed. when the int 0 pin interrupt is acknowledged, processing a is executed. each time the halt status is released, processing c is executed. if the int 0 pin interrupt request and timer interrupt request are issued at the same time in the halt status, processing a of the int 0 pin, which has the higher hardware priority, is executed. if reti is executed after execution of processing a, execution restores to the br loop instruction in <1>, but the br loop instruction is not executed, and the timer interrupt is immediately acknowledged. if reti is executed after processing b of the timer interrupt has been executed, the br loop instruction is executed.
m pd17016, 17017 124 caution when executing the halt instruction which is to be released if the interrupt request flag (irq ) for which the interrupt permission flag (ip ) is set is set, describe a nop instruction immediately before the halt instruction. if a nop instruction is described immediately before the halt instruction, a time of one instruction is generated in between the irq manipulation instruction and halt instruction. in the case of the clr1 irq instruction, for example, clearing irq is correctly reflected on the halt instruction (refer to example 1 below). if a nop instruction is not described immediately before the halt instruction, the clr1 irq instruction is not correctly reflected on the halt instruction, and the halt mode is not set (refer to example 2 below). example 1. program that correctly executes halt instruction ; sets irq clr1 irq nop ; describes nop instruction immediately before ; halt instruction ; (clearing irqxxx is correctly reflected on halt ; instruction) halt 1000b ; correctly executes halt instruction ; (halt mode is set) 2. program that does not set halt mode ; sets iqr clr1 irq ; clearing irqxxx is not reflected on halt instruction ; (but on instruction next to halt) halt 1000b ; halt instruction is ignored (halt mode is not set)
m pd17016, 17017 125 12.4.6 if two or more release conditions are simultaneously set if two or more release conditions are simultaneously set, and if even one of the conditions is satisfied, the halt status is released. the method to identify the release condition that is satisfied when two or more release conditions are specified is shown below. example 1. hltint dat 1000b hlttmr dat 0010b hltkey dat 0001b int0pin dat 0005h ; int 0 pin interrupt vector address symbol ; definition start: br main org int0pin processing a ; int 0 pin interrupt processing ei reti tmrup ; timer carry processing processing b ret keydec: ; key input processing processing c ret main: movt dbf, @ar ; sets key source output data (table reference) ; to key source data register (ksr) put ksr, dbf set2 ksen, lcden ; embedded macro ; multiplexes lcd segment signal output with ; key source signal output set2 btm0ck1, btm0ck0 ; embedded macro ; sets timer carry ff setting time to 1 ms set1_ip0 ; software macro ; enables int 0 pin interrupt ei loop: halt hltint or hlttmr or hltkey ; specifies interrupt, timer carry, and key input ; as halt release conditions skf1 btm0cy ; embedded macro ; detects tmcy flag call tmrup ; timer carry processing if set to 1 skf1 keyj ; embedded macro ; detects key input latch call keydec ; key input processing if latched br loop
m pd17016, 17017 126 in example 1 above, three halt release conditions are specified: int 0 pin interrupt, 1-ms timer carry, and key input. to detect which condition has caused the halt status to be released, the vector address, btm0cy flag, and keyj flag are detected to identify the interrupt, timer carry, and key input, respectively. when using two or more release conditions, the following two points must be noted. (1) all the specified release conditions must be detected when the halt status has been released. (2) the conditions must be sequentially detected starting from the one with the highest priority. for example, if the program below main: in example 1 above is as shown in example 2 below, care must be exercised. do not develop the program as shown in example 2 if the timer carry has a high priority. example 2. main: set4 p1c3, p1c2, p1c1, p1c0 ; uses general-purpose output port as key set2 btm0ck1, btm0ck0 ; source signal ; set1_ip0 ei loop: halt hltint or hlttmr or hltkey skf4 p0d3, p0d2, p0d1, p0d0 ; detects key input br keydec skf1 btm0cy call tmrup br loop keydec: ; key input processing processing c br loop in example 2 above, suppose the timer carry ff is set to 1 immediately after the halt status has been released by key input. then the program executes the halt instruction again after executing the key input processing. because the timer carry ff remains set at this time, the halt status is immediately released. usually, however, a high level is input for about 100 ms as key input. consequently, execution further branches to the key input processing. as a result, the timer carry ff is not correctly detected.
m pd17016, 17017 127 12.5 clock stop function the clock stop function stops the 4.5-mhz crystal oscillation circuit by executing the stop s instruction (clock stop status). therefore, the current consumption of the device is decreased to the minimum value of 15 m a. for the details on the current consumption, refer to 12.7 current consumption in halt status and clock stop status . specify 0000b as operand s of the stop s instruction. the stop s instruction is valid only while the ce pin is low. it is executed as a no-operation (nop) instruction even when executed while the ce pin is high. in other words, the stop s instruction must be executed while the ce pin is low. the clock stop status is released by raising the level of the ce pin from low to high (ce reset). the following subsections 12.5.1 through 12.5.3 explain the clock stop status, how to release the clock stop status, and notes on using the clock stop instruction. 12.5.1 clock stop status because the crystal oscillation circuit is stopped in the clock stop status, all the device operations, such as those of the cpu and peripheral hardware, are stopped. for the operations of the cpu and peripheral hardware, refer to 12.6 device operations in halt and clock stop status . the power failure detection circuit does not operate in the clock stop status even if the supply voltage v dd of the device is lowered to 2.2 v. therefore, the data memory can be backed up at a low voltage. for the details on the power failure detection circuit, refer to 13. reset . 12.5.2 releasing clock stop status the clock stop status is released either by raising the level of the ce pin from low to high (ce reset), or by lowering the supply voltage v dd of the device to 2.2 v or less once, and then increasing it to 4.5 v (power-on reset). figures 12-4 and 12-5 respectively show how the clock stop is released on ce reset and power-on reset. if the clock stop status is released by power-on reset, the power failure detection circuit operates. for the details on power-on reset, refer to 13.4 power-on reset .
m pd17016, 17017 128 figure 12-4. releasing clock stop status by ce reset figure 12-5. releasing clock stop status by power-on reset 5 v 0 v h l h l v dd ce pin x out pin stop s instruction program starts from address 0 (ce reset) operation is as follows if clock stop instruction is not used 5 v 0 v h l h l v dd ce pin x out pin 0 - t set program starts from address 0 (ce reset) ce reset is effected in synchronization with setting of timer carry ff after ce pin has gone high about 50 ms 5 v 0 v h l h l v dd ce pin x out pin operation is as follows if clock stop instruction is not used 5 v 0 v h l h l v dd ce pin x out pin stop s instruction about 50 ms program starts from address 0 (power-on reset) 2.2 v 3.5 v oscillation stops about 50 ms program starts from address 0 (power-on reset)
m pd17016, 17017 129 12.5.3 notes on using clock stop instruction the clock stop (stop s) instruction is valid only while the ce pin is low. therefore, processing to be performed if the ce pin happens to be high must be taken into consideration. take the following program as an example. example xtal dat 0000b ; symbol definition of clock stop condition cejdg: ; <1> skf1 ce ; embedded macro ; detects input level of ce pin br main ; branches to main processing if ce = high processing a ; processing of ce = low ; <2> stop xtal ; clock stop ; <3> br $ C 1 main: main processing br cejdg in the above example, the status of the ce pin is detected in <1>. if the ce pin is low, processing a is performed and then the clock stop instruction stop xtal in <2> is executed. if the ce pin goes high while the stop xtal instruction in <2> is executed, however, the stop xtal instruction is treated as a no-operation (nop) instruction. should branch instruction br$-1 in <3> be missing at this time, the program would execute the main processing, causing malfunctioning. therefore, either a branch instruction must be inserted as in <3>, or the program must be designed in the manner that malfunctioning does not occur even if the main processing is executed. if a branch instruction is used as in <3>, ce reset is executed in synchronization with the next setting of the timer carry ff even while the ce pin is high. 5 v 0 v h l v dd ce pin program starts from address 0 in synchronization with setting of timer carry ff (ce reset). main processing processing a < 1 > < 1 >< 1 > < 2 > stop xtal is treated as nop instruction because ce pin is high. detection of ce pin
m pd17016, 17017 130 12.6 device operations in halt and clock stop status table 12-1 shows the operations of the cpu and peripheral hardware in the halt status and clock stop status. as shown in this table, all the peripheral hardware units continue the normal operation in the halt status, except that instruction execution is stopped. all the peripheral hardware units stop operation in the clock stop status. the control registers that control the operations of the peripheral hardware units operate normally in the halt status (i.e., are not initialized), but are initialized to specific values in the clock stop status (as soon as the stop s instruction has been executed). to put in another way, the peripheral hardware units continue the operations set by the control registers in the halt status, and operate in accordance with the control registers that are initialized to specific values in the clock stop status. for the values to which the control registers are initialized, refer to 8. register file (rf) . table 12-1. device operations in halt status and clock stop status peripheral hardware status ce pin = high ce pin = low halt clock stop halt clock stop program counter stops at address of stop instruction is stops at address of initialized to 0000h halt instruction invalid (nop) halt instruction and stops system register retained retained initialized note peripheral register retained retained retained control register retained retained initialized note timer normal operation normal operation stops operation pll frequency synthesizer normal operation disabled disabled a/d converter normal operation normal operation stops operation d/a converter normal operation normal operation stops operation beep output normal operation normal operation stops operation serial interface normal operation normal operation stops operation frequency counter normal operation normal operation stops operation lcd controller/driver normal operation normal operation stops operation key source controller/ normal operation normal operation stops operation decoder general-purpose i/o port normal operation normal operation input port general-purpose input port normal operation normal operation input port general-purpose output normal operation normal operation retained port note for the value to which these registers are initialized, refer to 5. system register (sysreg) and 8. register file (rf) .
m pd17016, 17017 131 12.7 current consumption in halt status and clock stop status 12.7.1 device current consumption in halt status figure 12-6 shows the device current consumption i dd in the halt status. current consumption curves <1> through <4> in this figure were drawn by using the programs shown below. as shown in figure 12-6, the less the halt status is released, the lower the current consumption. (1) program 1 the halt instruction is not used. example nop br $ C 1 (2) program 2 a 5-ms timer interrupt is specified as the halt release condition, and 20 instructions (about 90 m s) are executed each time the halt status has been released. example hltint dat 1000b inttm dat 0003h br loop org tmint rept 17 nop endr ei reti loop: initflg btm1ck1, not btm1ck0 ; set_iptm ei halt hltint br $ C 1
m pd17016, 17017 132 (3) program 3 a 100-ms timer interrupt is specified as the halt release condition, and 20 instructions are executed each time the halt status has been released. example hltint dat 1000b inttm dat 0003h br loop org tmint rept 17 nop endr ei reti loop: clr2 btm1ck1, btm1ck0 ; set1_iptm ei halt hltint br $ C 1 (4) program 4 nothing is set as the halt release condition. example hltnorls dat 0000b halt hltnorls the device current consumption i dd shown in figure 12-6 were measured under the following conditions. ? pll is disabled. ? the frequency counter is disabled. ? a sine wave with a frequency f in = 4.5 mhz and input amplitude v in = v dd is input to the x in pin from a standard signal generator. ? all the pins set in the output mode are open. ? all the pins set in the input mode are pulled down by a 47-k w resistor (except the x in pin). 12.7.2 device current consumption in clock stop status figure 12-7 shows the device current consumption i dd in the clock stop status. the current consumption shown in this figure were measured under the following conditions. ? all the pins set in the output mode are open. ? all the pins set in the input mode are pulled down by a 47-k w resistor (except the x in pin). ? a crystal resonator is connected (however, oscillation is stopped).
m pd17016, 17017 133 figure 12-6. device current consumption in halt status (reference value) (a) i dd vs. v dd (t a = 25 c) (b) i dd vs. t a (v dd = 5.5 v) figure 12-7. device current consumption in clock stop status (reference value) (a) i dd vs. v dd (t a = 25 c) (b) i dd vs. t a (v dd = 5.5 v) 12.7.3 notes on processing each pin in halt and clock stop status the halt status is used to reduce the current consumption, for example, when only the watch operates. the clock stop function is used to reduce the current consumption when only the contents of the data memory are to be retained. therefore, the current consumption must be reduced as much as possible in the halt and clock stop statuses. at this time, the current consumption may increase depending on the status of each pin, and therefore the points shown in table 12-2 must be noted. supply voltage v dd (v) 1.5 1.0 0.5 0 3.5 4.0 4.5 5.0 5.5 supply current i dd (ma) (1) (2) (3) ambient temperature t a (c) 1.5 1.0 0.5 0 C40 supply current i dd (ma) (1) (2) (3) 0 25 85 (4) (4) supply voltage v dd (v) 3.0 2.0 1.0 0 2.2 ambient temperature t a (c) 3.0 2.0 1.0 0 C40 supply current i dd ( a) 0 25 85 2.5 3.0 3.5 4.0 4.5 5.0 5.5 supply current i dd ( a) m m
m pd17016, 17017 134 previous status before halt status is set is retained as is. (1) in output mode current consumption increases if these pins are externally pulled down while they output high level, or externally pulled up while they output low level. pay attention to n-ch open-drain output pins (p0a 3 , p0a 2 , and p1b 3 -p1b 0 ). (2) in input mode (except ports 1a and 1d) current consumption increases due to noise if these pins are floated. (3) port 0d (p0d 3 /adc 5 -p0d 0 /adc 2 ) current consumption increases if these pins are externally pulled up because they have pull-down resistor. however, pull-down resistor of pin selected as a/d converter pin is off. (4) ports 1d (p1d 3 /fmifc-p1d 0 / adc 0 ) and 1a (p1a 3 -p1a 0 ) current consumption increases when p1d 3 /fmifc and p1d 2 / amifc pins are used for if counter because internal amplifier operates. because if counter is not automatically disabled even if ce pin goes low, it must be initialized by program as necessary. ports 1d and 1a are designed to prevent increase in current consumption due to noise even if they are set in general purpose input port mode and floated. table 12-2. notes on status of each pin in halt and clock stop statuses (1/2) pin function pin symbol status of each pin and notes on processing halt clock stop general- port 0a p0a 3 purpose p0a 2 port p0a 1 p0a 0 port 0b p0b 3 p0b 2 /sck p0b 1 /so p0b 0 /si port 0c p0c 3 p0c 2 p0c 1 p0c 0 port 1a p1a 3 p1a 2 p1a 1 p1a 0 general- port 0d p0d 3 /adc 5 purpose p0d 2 /adc 4 input port p0d 1 /adc 3 p0d 0 /adc 2 port 1d p1d 3 /fmifc p1d 2 /amifc p1d 1 /adc 1 p1d 0 /adc 0 general- port 1b p1b 3 purpose p1b 2 /pwm 1 output port p1b 1 /pwm 0 p1b 0 /beep port 1c p1c 3 p1c 2 p1c 1 p1c 0 port 2a p2a 0 interrupt int 0 current consumption increase due to external noise if this pin is floated. all these pins are set in general-purpose input port mode. all input ports, except port 0c (p0c 3 - p0c 0 ), are designed to prevent increase in current consumption due to noise even if they are externally floated. port 0c (p0c 3 -p0c 0 ) must be externally pulled down or up so that current consumption does not increase due to noise. port 0d (p0d 3 /adc 5 -p0d 0 /adc 2 ) is internally pulled down. these pins are set in general-purpose output port pins. output contents are retained as is. therefore, current consumption increases if these pins are externally pulled down while they output high level, or pulled up while they output low level.
m pd17016, 17017 135 table 12-2. notes on status of each pin in halt and clock stop statuses (2/2) pin function pin symbol status of each pin and notes on processing halt clock stop lcd segment lcd 29 /p0f 3 | lcd 26 /p0f 0 lcd 25 /p0e 3 | lcd 22 /p0e 0 lcd 21 | lcd 16 lcd 15 /ks 15 | lcd 0 /ks 0 pll frequency vcol synthesizer vcoh eo 0 eo 1 crystal oscillation x in circuit x out same as above general-purpose output ports applies if these pins are used in general-purpose output port mode. if they output key source signals, current consumption increases via port 0d (with pull-down resistor) if there is switch that is always on such as transistor switch and if 1 is output as key source data. all pins are set in lcd segment signal output mode and output low level (display off). current consumption increases during pll operation. these pins are as follows when pll is disabled. vcol and vcoh : internally pulled down eo 0 and eo 1 : floated pll is automatically disabled when ce pin goes low. pll is disabled. these pins are as follows. vcol and vcoh : internally pulled down eo 0 and eo 1 : floated current consumption changes due to oscillation waveform of crystal oscillation circuit. current consumption decreases as oscillation amplitude increases. because oscillation amplitude is influenced by crystal resonator and load capacitor used, evaluation must be performed. x in pin is internally pulled down, and x out pin outputs high level.
m pd17016, 17017 136 13. reset the reset function is used to initialize the device operation. 13.1 configuration of reset block figure 13-1 shows the configuration of the reset block. the device is reset in two ways: by applying supply voltage v dd (power-on reset or v dd reset) and by using the ce pin (ce reset). the power-on reset block consists of a voltage detection circuit that detects a voltage input to the v dd pin, a power failure detection circuit, and a reset control circuit. the ce reset block consists of a circuit that detects the rising of a signal input to the ce pin, and a reset control circuit. figure 13-1. configuration of reset block selector timer carry divider reset control circuit control register system register stack program counter forced halt by timer carry reset signal ires res reset stop instruction rising detection circuit voltage detection circuit timer carry disable ff r s q btm0cy flag read stop s instruction power-on clear signal (poc) power failure detection block x out x in v dd ce timer ff block
m pd17016, 17017 137 13.2 reset function power-on reset is effected when supply voltage v dd rises from a specific level, and ce reset is effected when the ce pin goes high. power-on reset initializes the program counter, stack, system register, and control registers, and executes the program from address 0000h. ce reset initializes the program counter, stack, system register, and some control registers, and executes the program from address 0000h. the major differences between power-on reset and ce reset are the control registers that are initialized and the operation of the power failure detection circuit that is explained in 13.6. both power-on reset and ce reset are controlled by the reset signals ires, res, and reset output from the reset control circuit shown in figure 13-1. table 13-1 shows the relation among the ires, res, and reset signals, and power-on reset, and ce reset. the reset control circuit also operates when the clock stop instruction (stop s) explained in 12. standby is executed. the following sections 13.3 and 13.4 respectively explain ce reset and power-on reset. section 13.5 explains the relation between ce reset and power-on reset. table 13-1. relation between internal reset signals and each reset operation internal reset signal output signal control operation by each reset signal ce reset power-on clock stop reset ires forcibly sets device in halt status. halt status is released when timer carry ff is set. res initializes some control registers. reset initializes program counter, stack, system register, and some control registers.
m pd17016, 17017 138 13.3 ce reset ce reset is effected when the ce pin goes high. when the ce pin goes high, the reset signal is output in synchronization with the rising edge of the next timer carry ff setting pulse, and the device is reset. when ce reset is effected, the reset signal initializes the program counter, stack, system register, and some control registers, and the program is executed starting from address 0000h. for the value to which each of the above registers is initialized, refer to the description of each register. the operation of ce reset differs depending on whether the clock stop instruction is used. the differences in operation are explained in the following subsections 13.3.1 and 13.3.2. subsection 13.3.3 explains the points to be noted on using ce reset. 13.3.1 ce reset when clock stop (stop s) instruction is not used figure 13-2 shows the operation of ce reset when the clock stop (stop s) instruction is not used. when the stop s instruction is not used, the timer mode select register of the control registers is not initialized. after the ce pin has gone high, therefore, the reset signal is output at the rising edge of the timer carry ff setting pulse (1 ms, 5 ms, 100 ms, 250 ms) selected at that time, and the device is reset. figure 13-2. ce reset operation when clock stop instruction is not used 5 v 0 v h l h l h l h l h l h l v dd ce x out timer carry ff setting pulse ires res reset normal operation normal operation ce reset is effected at rising of timer carry ff setting pulse. if selected timer carry ff setting time is t set , this period t is 0 < t < t set depending on timing of rising of ce pin. durin g this period, pro g ram continues its operation. reset signals
m pd17016, 17017 139 13.3.2 ce reset when clock stop (stop s) instruction is used figure 13-3 shows the operation of ce reset when the clock stop (stop s) instruction is used. when the stop s instruction is used, the ires, res, and reset signals are output as soon as the stop s instruction has been executed. at this time, the timer mode select register of the control registers is initialized to 0000b by the res signal, the timer carry ff setting signal is set to 100 ms. because the ires signal is output while the ce pin is low, the halt status, which can be released by the timer carry, is forcibly set. however, the device stops operation because the clock is stopped. when the ce pin goes high, the clock stop status is released, and oscillation starts. because the halt status that can be released by the timer carry is set at this time by the ires signal, the program starts from address 0 when the ce pin goes high and then the timer carry ff setting pulse rises. because the timer carry ff setting pulse is initialized to 100 ms, ce reset is effected 50 ms after the ce pin has gone high. figure 13-3. ce reset operation when clock stop instruction is used 5 v 0 v h l h l h l h l h l h l v dd ce x out ires res reset normal operation timer carry ff setting pulse clock stop status halt status stop s instruction clock oscillation starts stop released ce reset program starts from address 0. 50 ms reset signals
m pd17016, 17017 140 13.3.3 notes on ce reset because ce reset is effected regardless of the instruction under execution, the following points <1> and <2> must be noted. (1) time to execute timer processing such as watch when developing a watch program by using the timer carry or timer interrupt, the processing of that program must be completed in specific time. for details, refer to 11.3.7 notes on using timer carry and 11.4.5 notes on using timer interrupt . (2) processing of data and flag used for program care must be exercised in rewriting the contents of data or flag that cannot be processed with one instruction and whose contents must not change even when ce reset is effected, such as a security code. this is explained in detail by using the following examples.
m pd17016, 17017 141 example 1. r1 mem 0.01h ; first digit of key input data of security code r2 mem 0.02h ; second digit of key input data of security code r3 mem 0.03h ; first digit data for changing security code r4 mem 0.04h ; second digit data for changing security code m1 mem 0.11h ; first digit of current security code m2 mem 0.12h ; second digit of current security code start: key input processing r1 contents of key a ; security code input wait mode r2 contents of key b ; substitutes contents of pressed key into r1 and r2. set2 cmp, z ;<1> ; compares security code with input data. sub r1, m1 sub r2, m2 skt1 z br error ; input data is different from security code. main: key input processing r3 contents of key c ; security code rewriting mode r4 contents of key d ; substitutes contents of pressed key into r3 and r4. st m1, r3 ;<2> ; rewrites security code. st m2, r4 ;<3> br main error: must not operate suppose the current security code is 12h in the above program, the contents of data memory areas m1 and m2 are 1h and 2h, respectively. if ce reset is effected, the contents of key input are compared with security code 12h in <1>. if they coincide, the normal processing is performed. if the security code is changed by the main processing, the new code is written to m1 and m2 in <2> and <3>. suppose the security code is changed to 34h, 3h and 4h are written to m1 and m2, respectively, in <2> and <3>. if ce reset is effected at the point where <2> is executed, the program is executed from address 0000h without <3> executed. consequently, the security code is changed to 32h, making impossible to clear the security. in this case, use the program shown in following example 2.
m pd17016, 17017 142 example 2. r1 mem 0.01h ; first digit of key input data of security code r2 mem 0.02h ; second digit of key input data of security code r3 mem 0.03h ; first digit data for changing security code r4 mem 0.04h ; second digit data for changing security code m1 mem 0.11h ; first digit of current security code m2 mem 0.12h ; second digit of current security code change flg 0.13h.0 ; 1 while security code is changed start: key input processing r1 contents of key a ; security code input wait mode r2 contents of key b ; substitutes contents of pressed key into r1 and r2. skt1 change ;<4> ; if change flag is 1 br security_chk st m1, r3 ; rewrites m1 and m2. st m2, r4 clr1 change security_chk: set2 cmp, z ;<1> ; compares security code with input data. sub r1, m1 sub r2, m2 skt1 z br error ; input data is different from security code. main: key input processing r3 contents of key c ; security code rewriting mode r4 contents of key d ; substitutes contents of pressed key into r3 and r4. set1 change ;<5> ; until security code is changed ; sets change flag to 1. st m1, r3 ;<2> ; rewrites security code st m2, r4 ;<3> clr1 change ; when security code has been changed, sets ; change flag to 0. br main error: must not operate in the program in example 2, the change flag is set to 1 in <5> before the security code is changed in <2> and <3>. therefore, the security code is rewritten in <4> even if ce reset is effected before <3> is executed.
m pd17016, 17017 143 13.4 power-on reset power-on reset is effected when the supply voltage v dd of the device rises from a specific level (called power- on clear voltage). if the supply voltage v dd is lower than the power-on clear voltage, a power-on clear signal (poc) is output from the voltage detection circuit shown in figure 13-1. when the power-on clear voltage is output, the crystal oscillation circuit is stopped, and the device operation is stopped. while the power-on clear signal is output, the ires, res, and reset signals are output. if supply voltage v dd exceeds the power-on clear voltage, the power-on clear signal is cleared, and crystal oscillation is started. at the same time, the ires, res, and reset signals are also cleared. at this time, the halt status is set to be released by the timer carry due to the ires signal. therefore, power- on reset is effected at the rising edge of the next timer carry ff setting signal. the timer carry ff setting signal is initialized to 100 ms by the reset signal. for this reason, reset is effected 50 ms after supply voltage v dd has exceeded the power-on clear voltage, and the program is started from address 0. this operation is illustrated in figure 13-4. the program counter, stack, system register, and control registers are initialized as soon as the power-on clear signal has been output. for the value to which each of the above registers is to be initialized, refer to the description of each register. the power-on clear voltage is 3.5 v (rated value) during normal operation, and 2.2 v (rated value) in the clock stop status. the operations performed when the power-on clear voltage is at the respective levels are explained in 13.4.1 and 13.4.2. the operation to be performed if the supply voltage v dd rises from 0 v is explained in 13.4.3. figure 13-4. operation of power-on reset 5 v 0 v h l h l h l h l h l h v dd ce x out ires res reset normal operation timer carry ff setting pulse device operation stops halt status power-on clear released oscillation starts power-on reset program starts from address 0. 50 ms l h l power-on clear signal power-on clear voltage reset signals
m pd17016, 17017 144 13.4.1 power-on reset during normal operation figure 13-5 (a) shows the operation. as shown in the figure, the power-on clear signal is output and the device operation stops regardless of the input level of the ce pin, if the supply voltage v dd drops below 3.5 v. if v dd rises beyond 3.5 v again, the program starts from address 0000h after 50 ms of halt status. the normal operation is when the clock stop instruction is not used and includes the halt status that is set by the halt instruction. 13.4.2 power-on reset in clock stop status figure 13-5 (b) shows the operation. as shown in the figure, the power-on clear signal is output and the device operation stops if supply voltage v dd drops below 2.2 v. however, it seems as if the device operation were not changed because the device is in the clock stop status. when supply voltage v dd rise beyond 3.5 v next time, the program starts from address 0000h after 50 ms of halt status. 13.4.3 power-on reset when supply voltage v dd rises from 0 v figure 13-5 (c) shows the operation. as shown in the figure, the power-on clear signal is output until supply voltage v dd rises from 0 v to 3.5 v. when v dd rises beyond the power-on clear voltage, the crystal oscillation circuit starts operating, and the program starts from address 0000h after 50 ms of halt status.
m pd17016, 17017 145 figure 13-5. power-on reset and supply voltage v dd (a) during normal operation (including halt status) (b) in clock stop status (c) when supply voltage v dd rises from 0 v 5 v 0 v h l h l h v dd ce x out l power-on clear signal power-on clear voltage normal operation device operation stops halt status 50 ms power-on clear released oscillation starts power-on reset program starts from address 0. 3.5 v 5 v 0 v h l h l h v dd ce x out l power-on clear signal 2.2 v 3.5 v power-on clear voltage normal operation device operation stops halt status 50 ms power-on clear released oscillation starts power-on reset program starts from address 0. stop s instruction clock stop 5 v 0 v h l h l h v dd ce x out l power-on clear signal power-on clear voltage 3.5 v device operation stops halt status 50 ms power-on clear released oscillation starts power-on reset program starts from address 0.
m pd17016, 17017 146 13.5 relation between ce reset and power-on reset there is a possibility that power-on reset and ce reset are effected at the same time when power is first applied. the reset operations performed at this time are explained in 13.5.1 through 13.5.3. 13.5.4 explains the points to be noted in raising supply voltage v dd . 13.5.1 if v dd pin and ce pin rise simultaneously figure 13-6 (a) shows the operation. at this time, the program starts from address 0000h due to power-on reset. 13.5.2 if ce pin rises in forced halt status of power-on reset figure 13-6 (b) shows the operation. at this time, the program starts from address 0000h due to power-on reset in the same manner as in 13.5.1. 13.5.3 if ce pin rises after power-on reset figure 13-6 (c) shows the operation. at this time, the program starts from address 0000h due to power-on reset, and the program starts from address 0000h again at the rising of the next timer carry ff setting signal because of ce reset.
m pd17016, 17017 147 figure 13-6. relation between power-on reset and ce reset (a) if v dd and ce pins rise simultaneously 5 v 0 v h l h v dd ce l timer carry ff setting pulse 3.5 v power-on clear voltage halt status 50 ms normal operation power-on reset program starts operation stops (b) if ce pin rises in halt status (c) if ce pin rises after power-on reset 5 v 0 v h l h v dd ce l timer carry ff setting pulse halt status 50 ms normal operation power-on reset program starts power-on clear voltage 3.5 v operation stops 5 v 0 v h l h v dd ce l timer carry ff setting pulse halt status 50 ms normal operation power-on reset pro g ram starts power-on clear voltage 3.5 v ce reset pro g ram starts operation stops
m pd17016, 17017 148 13.5.4 notes on raising supply voltage v dd when raising supply voltage v dd , keep in mind the following points (1) and (2). (1) when raising supply voltage v dd from power-on clear voltage it is necessary to raise supply voltage v dd to higher than 3.5 v at least once. this is illustrated in figure 13-7. suppose, for example, only a voltage less than 3.5 v is applied on application of v dd with a program that backs up v dd at 2.2 v by using the clock stop instruction, as shown in figure 13-7, the power-on clear signal is continuously output, and the program does not operate. because the output ports of the device output undefined values, the current consumption increases in some cases. if the device is backed up by batteries, therefore, the back-up time is substantially shortened. figure 13-7. notes on raising v dd 5 v 0 v h l h v dd ce l timer carry ff setting pulse h l h l 3.5 v 2.2 v x out power-on clear signal operation stops opera- tion stops halt status 50 ms normal operation back up current consumption may increase during this period because output ports are undefined. power-on reset pro g ram starts stop s instruction power-on clear voltage initialization is executed during this period, and then clock stop instruction is executed.
m pd17016, 17017 149 (2) restoring from clock stop status to restore the device from the back-up status while supply voltage v dd is backed up at 2.2 v by using the clock stop instruction, v dd must be raised to 3.5 v or higher within 50 ms after the ce pin has gone high. as shown in figure 13-8, the device is restored from the clock stop status by means of ce reset. because the power-on clear voltage is changed to 3.5 v 50 ms after the ce pin has gone high, power-on reset is effected unless v dd is 3.5 v or higher at this point. the same applies when v dd is lowered. figure 13-8. restoring from clock stop status 5 v 0 v h l h v dd ce l timer carry ff setting pulse h l h l 3.5 v 2.2 v x out power-on clear signal power-on clear voltage back up by clock stop instruction halt status 50 ms normal operation processing where ce = low back up ce reset program starts stop s instruction power-on clear voltage is changed to 3.5 v at this point. therefore, v dd must rise to 3.5 v or hi g her before this point. power-on clear voltage is changed to 2.2 v at this point. therefore, v dd must not fall below 3.5 v before this point.
m pd17016, 17017 150 13.6 power failure detection power failure detection is used to judge whether power-on reset by application of supply voltage v dd , or ce reset has been effected when the device is reset, as shown in figure 13-9. because the contents of the data memory and ports are undefined on power application, these contents are initialized by means of power failure detection. a power failure can be detected in two ways: by using the power failure detection circuit to detect the btm0cy flag, and by detecting the contents of the data memory (ram judgement). 13.6.1 and 13.6.2 explain how a power failure is detected by using the power failure detection circuit and btm0cy flag. 13.6.3 and 13.6.4 explain how a power failure is detected by ram judgement method. figure 13-9. power failure detection flow chart program starts power failure detection power failure not power failure initializes data memory and output ports 13.6.1 power failure detection circuit the power failure detection circuit consists of a voltage detection circuit, a timer carry disable flip-flop that is set by the output (power-on clear signal) of the voltage detection circuit, and a timer carry, as shown in figure 13-1. the timer carry disable ff is set to 1 by the power-on clear signal, and is reset to 0 when an instruction that reads the btm0cy flag is executed. when the timer carry disable ff is set to 1, the btm0cy flag is not set to 1. when the power-on clear signal is output (at power-on reset), the program is started with the btm0cy flag reset, and the btm0cy flag is disabled from being set until an instruction that reads the btm0cy flag is executed. once the instruction that reads the btm0cy flag has been executed, the btm0cy flag is set each time the timer carry ff setting pulses has risen. it can be judged whether power-on reset (power failure) or ce reset (not power failure) has been effected by detecting the contents of the btm0cy flag when the device is reset. power-on reset has been effected if the btm0cy flag is reset to 0; ce reset has been effected if it is set to 1. the voltage at which a power failure can be detected is the same as the voltage at which power-on reset is effected, or v dd = 3.5 v during crystal oscillation, or v dd = 2.2 v in the clock stop status. figure 13-10 shows the transition of the status of the btm0cy flag. figures 13-11 and 13-10 show the timing chart and the operation of the btm0cy flag.
m pd17016, 17017 151 figure 13-10. status transition of btm0cy flag ce = low ce = any ce = high < 1 > v dd = low operation stops crystal oscillation starts forced halt (approx. 50 ms) power-on reset < 2 > clock stop < 5 > ce reset normal operation stop 0 ce = h ? l disables setting of btm0cy flag. normal operation ce reset wait crystal oscillation starts forced halt (50 ms) skt1 btm0cy or skf1 btm0cy btm0cy = 0 timer carry ff setting pulse rises. ce = l ce = h skt1 btm0cy or skf1 btm0cy ce = l ? h ce = l ? h clock stop ce reset stop 0 ce = h ? l enables setting of btm0cy flag normal operation ce reset wait crystal oscillation starts forced halt (50 ms) btm0cy = 1 timer carry ff setting pulse rises. ce = l ? h ce = l ? h v dd = l ? 3.5 v < 3 > normal operation < 7 > < 8 > < 9 > < 10 > < 11 > <12 > < 13 > normal operation normal operation < 14 > < 15 > < 16 > < 17 > < 4 > < 6 >
m pd17016, 17017 152 figure 13-11. operation of btm0cy flag (a) when btm0cy flag never detected (skt1 btm0cy or skf1 btm0cy is not executed) (b) when detecting power failure by btm0cy flag 5 v 0 v h l h l h v dd ce l timer carry ff setting pulse btm0cy operation in figure 13-10 timer time changed stop 0000 b < 1 > < 2 > < 6 > < 8 > < 6 > < 5 > < 4 > < 9 > < 6 > < 1 > < 7 > < 7 > < 3 > < 5 > 5 v 0 v h l h l h v dd ce l timer carry ff setting pulse btm0cy operation in figure 13-10 timer time changed stop 0000 b btm0cy = 0 power failure btm0cy = 1 not power failure btm0cy = 1 not power failure < 1 > < 2 > <6> <14> < 13 > < 16 > < 14 > < 13 > < 12 > < 17 > < 14 > < 1 > < 15 > < 15 > < 3 > < 11 > skt1 btm0cy instruction
m pd17016, 17017 153 13.6.2 notes on detecting power failure by btm0cy flag the following points must be noted when using the btm0cy flag for watch counting. (1) updating watch when developing a watch program by using the timer carry, the watch must be updated after a power failure has been detected. this is because counting of the watch is skipped once because the btm0cy flag is reset to 0 when the btm0cy flag is read on detection of a power failure. (2) watch updating processing time the processing to update the watch must be completed before the next timer carry ff setting pulse rises. this is because, if the ce pin goes high during the watch updating processing, ce reset is effected without the watch updating processing completed. for further information on (1) and (2) above, refer to 11.3.7 (b) correction of timer carry on ce reset . when detecting a power failure, the following points must be noted. (3) timing of power failure detection to count the watch by using the btm0cy flag, the btm0cy flag must be read to detect a power failure within the time since the program has started from address 0000h until the next timer carry ff setting pulse rises. for example if the timer carry ff setting time is set to 5 ms, and a power failure is detected 6 ms after the program has been started, the btm0cy flag is overlooked once. for details, refer to 11.3.7 (b) correction of timer carry on ce reset . power failure detection and initial processing must be completed within the timer carry ff setting time as shown in the following example. this is because, if the ce pin goes high and ce reset is effected during power failure detection processing and initial processing, these processing may be stopped in midway, and thus problems may occur. to change the timer carry ff setting time by the initial processing, the instruction that changes the time must be executed at the end of the initial processing, and the instruction must be one instruction. this is because the initial processing may not be completely executed because of ce reset if the timer carry ff setting time is changed before the initial processing is executed, as shown in the following example.
m pd17016, 17017 154 example start: ; program address 0000h ;<1> processing on reset ;<2> skt1 btm0cy ; power failure detection br initial backup: ;<3> watch updating br main initial: ;<4> initial processing ;<5> initflg btm0ck1, not btm0ck0 ; embedded macro ; sets timer carry ff setting time to 5 ms main: main processing skt1 btm0cy br main watch updating br main
m pd17016, 17017 155 example of operation 5 v 0 v h l h l v dd ce timer carry ff setting pulse 50 ms 5 ms < 2 > power failure detection if processing time of < 1 > + < 4 > is longer than 100 ms, ce reset is effected in middle of processing < 4 >. if processing time of < 1 > + < 3 > is too long, ce reset is effected. < 5 > ce reset ce reset 50 ms 5-ms pulse 50-ms pulse < 1 > < 4 > < 1 > < 3 > < 2 > power failure detection ce reset may be effected immediately depending on when timer carry ff setting time is changed. therefore, if < 5 > is executed before < 4 >, power failure processing < 4 > may not be completely executed. 13.6.3 power failure detection by ram judgement method the ram judgement method is to detect a power failure by judging whether the contents of the data memory at a specific address are the specified value. an example of a program that detects a power failure by the ram judgement method is shown below. the ram judgement method detects a power failure by comparing an undefined value with the specified value because the contents of the data memory are undefined on application of supply voltage v dd . therefore, there is a possibility that a wrong judgment may be made as explained in 13.6.4 notes on detecting power failure by ram judgement method . when the ram judgement method is used, however, the device can be backed up at a voltage lower than that at which a power failure is detected, by using the power failure detection circuit, as shown in table 13-2. table 13-2. comparing power failure detection by power failure detection circuit and ram judgement method power failure detection circuit ram judgement method data hold voltage effective value rated value effective value rated value (in clock stop status) 1-2 v 2.2 v 0-1 v 2.0 v operating status no malfunctioning malfunctioning may occur
m pd17016, 17017 156 example program to detect power failure by ram judgement method m012 mem 0.12h m034 mem 0.34h m056 mem 0.56h m107 mem 1.07h m128 mem 1.28h m16f mem 1.6fh data0 dat 1010b data1 dat 0101b data2 dat 0110b data3 dat 1001b data4 dat 1100b data5 dat 0011b start: set2 cmp, z sub m012, #data0 ; if m012 = data0 and sub m034, #data1 ; m034 = data1 and sub m056, #data2 ; m035 = data2 and bank1 sub m107, #data3 ; m107 = data3 and sub m128, #data4 ; m128 = data4 and sub m16f, #data5 ; m16f = data5, bank0 skf1 z br backup ; branches to backup ;initial: initial processing mov m012, #data0 mov m034, #data1 mov m056, #data2 bank1 mov m107, #data3 mov m128, #data4 mov m16f, #data5 br main backup: backup processing main: main processing
m pd17016, 17017 157 13.6.4 notes on detecting power failure by ram judgement method the value of the data memory on application of supply voltage v dd is basically undefined, and therefore, the following points (1) and (2) must be noted. (1) data to be compared where the number of bits of the data memory to be compared by the ram judgement method is n bits, the probability at which the value of the data memory coincides with the value to be compared on application of v dd is (1/2) n . this means that backup is judged at a probability of (1/2) n when a power failure is detected by the ram judgement method. to lower this probability, as many bits as possible must be compared. because the contents of the data memory on application of v dd are likely to be the same value such as 0000b and 1111b, it is recommended to mix 0 and 1 as data to be compared, such a 1010b and 0110b to reduce the possibility of a wrong judgment. (2) notes on program if v dd rises from the level at which the data memory contents may be destroyed as shown in figure 13- 12, and even if the value of the data memory area to be compared is normal, the values of the other data memory areas may be destroyed. this is judged as backup if a power failure is detected by the ram judgement method. therefore, consideration must be given so that the program does not hang up even if the contents of the data memory are destroyed. figure 13-12. v dd and destruction of data memory contents data memory destruction start voltage 5 v 0 v v dd values of data memor y areas not used for ram j ud g ement ma y be destro y ed. data memory for ram judgement (normal) data memory
m pd17016, 17017 158 14. pll frequency synthesizer the pll (phase locked loop) frequency synthesizer is used to lock the frequency in the mf (medium frequency), hf (high frequency), and vhf (very high frequency) bands to a specific frequency by comparing phase differences. 14.1 configuration of pll frequency synthesizer figure 14-1 shows the block diagram of the pll frequency synthesizer. as shown in the figure, the pll frequency synthesizer consists of an input select block, programmable divider (pd), phase comparator ( f -det), reference frequency generator (rfg), and charge pump. by connecting these blocks with an external lowpass filter (lpf) and voltage-controlled oscillator (vco), a pll frequency synthesizer is organized. figure 14-1. block diagram of pll frequency synthesizer note external circuit control register input select block programmable divider (pd) phase comparator ( -det) charge pump unlock detection block voltage-controlled oscillator (vco) lowpass filter (lpf) reference frequency generator (rfg) note note eo 1 eo 0 vcoh vcol data buffer f
m pd17016, 17017 159 14.2 functional outline of pll frequency synthesizer the pll frequency synthesizer divides a signal input from the vcoh (pin 32) or vcol (pin 31) pin by using the programmable divider and outputs a phase difference from the reference frequency from the eo 1 and eo 0 pins. the pll frequency synthesizer operates only when the ce pin is high, and is disabled when the ce pin is low. for the details on the disable status of the pll frequency synthesizer, refer to 14.6 . the following subsections 14.2.1 through 14.2.6 outline the function of each block of the pll frequency synthesizer. 14.2.1 input select block this block selects the pin from which a signal output from an external voltage-controlled oscillator is input. as the input pin, the vcoh or vcol pin is selected by the pll mode select register (rf address 21h). for details, refer to 14.3 . 14.2.2 programmable divider the programmable divider divides the signal input from the vcoh or vcol pin at the division ratio set by the program. two types of division modes can be selected: direct division and pulse swallow modes. the division mode is selected by the pll mode select register. the division ratio is set by the pll data register (pllr: peripheral address 41h) via the data buffer. for details, refer to 14.3 . 14.2.3 reference frequency generator this generator generates a reference frequency to be compared by the phase comparator. twelve types of reference frequencies can be selected by using the pll reference mode select register (rf address 31h). for details, refer to 14.4 . 14.2.4 phase comparator and unlock detection block the phase comparator compares the division signal output by the programmable divider with the signal from the reference frequency generator, and outputs a phase difference. the unlock detection block detects the unlock status of the pll. the unlock status of the pll is detected by the pll unlock ff judge register (rf address 05h). for details, refer to 14.5 . 14.2.5 charge pump the charge pump outputs the signal output by the phase comparator to the eo 1 an eo 0 pins as a high-level, low-level, or floating signal. for details, refer to 14.5 .
m pd17016, 17017 160 14.3 input select block and programmable divider 14.3.1 configuration of input select block and programmable divider figure 14-2 shows the configuration of the input select block and programmable divider. as shown in the figure, the input select block consists of the vcoh and vcol pins, and the amplifiers of the respective pins. the programmable divider consists of a 2-modulus prescaler, swallow counter, programmable counter, and division mode select switch. figure 14-2. configuration of input select block and programmable divider address bit flag symbol control register 21h b 3 b 2 b 1 b 0 data buffer (dbf) 0ch dbf3 m s b 0dh dbf2 0eh dbf1 0fh dbf0 l s b address symbol data 16 pll data register 12 bits 4 bits 12 4 swallow counter 4 bits programmable counter 12 bits f n to -det mf vhf hf 2-modulus prescaler 1/16, 1/17 hf mf vhf pll disable signal mf hf vhf vcoh vcol 2-4 decoder psc peripheral address 41h f p l l m d 3 p l l m d 2 p l l m d 1 p l l m d 0
m pd17016, 17017 161 14.3.2 functions of input select block and programmable divider the input select block and programmable divider selects the input pin and division mode of the pll frequency synthesizer. as the input pin, the vcoh or vcol pin can be selected. the selected pin goes into an intermediate-potential state (approx. 1/2 v dd ). the pin not selected is internally pulled down. these pins input signals via an ac amplifier, and the dc component of the input signal must be cut off by connecting a capacitor to the pin in series. either the direct division mode or pulse swallow mode can be selected as the division mode. the programmable counter divides the signal input from the vcoh or vcol pin in a specified division mode according to the values set to the swallow counter and programmable counter. table 14-1 show the input pins (vcoh and vcol) and division modes. the input pin and division mode to be used are selected by the pll mode select register. 14.3.3 explains the configuration and function of the pll mode select register. the division ratio is set to the programmable divider by the pll data register via the data buffer. 14.3.4 explains the programmable divider and pll data register. table 14-1. input pins and division modes division mode pin input frequency input amplitude settable division division ratio settable in (mhz) (v p-p ) ratio data buffer direct division vcol 0.5-30 0.2 16 to 2 12 C 1 010 h-fff h (mf) ( : low-order 4 bits are dont care) pulse swallow vcol 5-40 0.2 256 to 2 16 C 1 0100h-ffffh (hf) pulse swallow vcoh 9-150 0.2 256 to 2 16 C 1 0100h-ffffh (vhf) ----------------------------
m pd17016, 17017 162 14.3.3 configuration and function of pll mode select register the pll mode select register specifies the division mode of the pll frequency synthesizer and the pin to be used. the configuration and function of the pll mode select register are shown below. the paragraphs (1) through (4) below outlines the respective division modes. (1) direct division mode (mf) in this mode, the vcol pin is used. the vcoh pin is pulled down. in the direct division mode, the frequency of the input signal is divided only by the programmable counter. (2) pulse swallow mode (hf) the vol pin is used in this mode. the vcoh pin is pulled down. in this mode, the frequency of the input signal is divided by the swallow counter and programmable counter. (3) pulse swallow mode (vhf) the vcoh pin is used in this mode. the vcol pin is pulled down. in this mode, the frequency of the input signal is divided by the swallow counter and programmable counter. (4) disabling vcol and vcoh pins the vcoh and vcol pins are internally pulled down. however, the phase comparator, reference frequency generator, and charge pump operate. therefore, the operation is different from that in the pll disable status to be explained later. name flag symbol b 3 b 2 b 1 b 0 address 21h read/ write r/w 0 0 1 1 0 1 0 1 sets division mode of pll frequency synthesizer disables vcol and vcoh pins direct division mode (vcol pin, mf mode) pulse swallow (vcoh pin, vhf mode) pulse swallow (vcol pin, hf mode) power-on clock stop ce 000 0 0 0 pll mode select register fixed to 0 retained p l l m d 3 p l l m d 2 p l l m d 1 p l l m d 0 on reset
m pd17016, 17017 163 14.3.4 programmable divider and pll data register the programmable divider divides the signal input from the vcoh or vcol pin by the value set to the swallow counter and programmable counter. the swallow counter and programmable counter are 4-bit binary down counters. the division ratio is set to the swallow counter and programmable counter by the pll data register (pllr: peripheral address 41h) via data buffer. data is set to or read from the pll data register by using the put pllr, dbf or get dbf, pllr instruction. the value to be divided is called n value. for how to set the n value in each division mode, refer to 14.7 . (1) pll data register and data buffer the relation between the pll data register and data buffer is explained next. in the direct division mode, the high-order 12 bits are valid, and all the 16 bit are valid in the pulse swallow mode. in the direct division mode, all the high-order 12 bits are set to the programmable counter. in the pulse swallow mode, the high-order 12 bits are set to the programmable counter, and the low-order 4 bits are set to the swallow counter. (2) relation between division value n and divided output frequency the relation between the value n set to the pll data register and the frequency f n of the signal divided and output by the programmable divider is as follows. for details, refer to 14.7 . (a) in direct division mode (mf) f in f n = n: 12 bits n (b) in pulse swallow mode (hf and vhf) f in f n = n: 16 bits n
m pd17016, 17017 164 name symbol address bit data data buffer dbf3 0ch dbf2 0dh dbf1 0eh dbf0 0fh b 3 b 2 b 1 b 0 b 3 b 2 b 1 b 0 b 3 b 2 b 1 b 0 b 3 b 2 b 1 b 0 transfer data 16 get can be executed put can be executed b 15 b 14 b 13 b 12 b 11 b 10 b 9 b 8 b 7 b 6 b 5 b 4 b 3 b 2 b 1 b 0 name pll data register peripheral register symbol pllr valid data 41h peripheral address pll frequency synthesizer sets division ratio of pll frequency synthesizer 0 15 (00fh) 16 (010h) x 2 12 C1 (fffh) 0 255 (00ffh) 256 (0100h) x 2 16 C1 (ffffh) don't care don't care don't care don't care don't care direct division mode setting prohibited division ratio n: n = x setting prohibited division ratio n: n = x peripheral address pulse swallow mode
m pd17016, 17017 165 14.4 reference frequency generator 14.4.1 configuration and function of reference frequency generator figure 14-3 shows the configuration of the reference frequency generator. as shown in the figure, the reference frequency generator divides 4.5 mhz of the crystal oscillation circuit to generate the reference frequency f r of the pll frequency synthesizer. twelve reference frequencies can be selected: 1, 1.25, 2.5, 3, 5, 6.25, 9, 10, 12.5, 25, 50, and 100 khz. reference frequency f r is selected by the pll reference mode select register. 14.4.2 shows the configuration and function of the pll reference mode select register. figure 14-3. configuration of reference frequency generator (rfg) address bit flag symbol control register 31h b 3 b 2 b 1 b 0 4-16 decoder mux pll disable signal to -det divider 4.5 mhz 1 khz 1.25 khz 3 khz 50 khz 100 khz p l l r f c k 3 p l l r f c k 2 p l l r f c k 1 p l l r f c k 0 f
m pd17016, 17017 166 14.4.2 configuration and function of pll reference mode select register the configuration and function of the pll reference mode select register are shown below. when the pll is disabled by the pll reference mode select register, the vcoh and vcol pins are internally pulled down. the eo 1 and eo 0 pins are floated. for disabling the pll, refer to 14.6 . name flag symbol b 3 b 2 b 1 b 0 address 31h read/ write r/w 0 0 1 1 0 0 1 1 0 0 1 1 0 0 1 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 sets reference frequency f r of pll frequency synthesizer 1.25 khz 2.5 khz 5 khz 10 khz 6.25 khz 12.5 khz 25 khz 50 khz 3 khz setting prohibited setting prohibited setting prohibited 1 khz 9 khz 100 khz pll disabled power-on clock stop ce 1 1 1 1 1 1 1 1 pll reference mode select register retained 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 0 0 0 0 1 1 1 1 0 0 0 0 1 1 1 1 p l l r f c k 3 p l l r f c k 2 p l l r f c k 1 p l l r f c k 0 on reset
m pd17016, 17017 167 14.5 phase comparator ( f -det), charge pump, and unlock detection block 14.5.1 configuration of phase comparator, charge pump, and unlock detection block figure 14-4 shows the configuration of the phase comparator, charge pump, and unlock detection block. the phase comparator compares the divided frequency output f n of the programmable divider with the reference frequency output f r of the reference frequency generator, and outputs an up request (up) or down request (dw) signal. the charge pump outputs the output of the phase comparator from the error out (eo 1 and eo 0 ) pins. the unlock detection block detects the unlock status of the pll frequency synthesizer. the following subsections 14.5.2 through 14.5.4 respectively explain the operations of the phase comparator, charge pump, and unlock detection block. figure 14-4. configuration of phase comparator, charge pump, and unlock detection block address bit flag symbol control register 05h b 3 0 b 2 0 b 1 0 b 0 p l l u l unlock detection block unlock ff charge pump v dd p-ch n-ch p-ch n-ch v dd eo 1 eo 0 dw pll disable signal up phase comparator ( -det) f n reference frequency generator programmable divider f r f
m pd17016, 17017 168 14.5.2 function of phase comparator as shown in figure 14-4, the phase comparator compares the divided frequency output f n of the programmable divider with the reference frequency output f r of the reference frequency generator, and outputs an up request or down request signal. if the divided frequency f n is lower than the reference frequency f r , the phase comparator outputs the up request signal; if f n is higher than f r , it outputs the down request signal. figure 14-5 shows the relation among the reference frequency f r , divided frequency f n , up request signal, and down request signal. when the pll is disabled, neither the up request nor down request signal is output. the up request and down request signals are respectively input to the charge pump and unlock detection block. figure 14-5. relation among f r , f n , up, and dw (a) if f n is behind f r in phase (b) if f n leads f r in phase (c) if f n and f r are in phase (d) if f n is lower than f r in frequency f r f n up dw f r f n up dw f r f n up dw f r f n up dw
m pd17016, 17017 169 14.5.3 charge pump as shown in figure 14-4, the charge pump outputs the up request signal or down request signal from the phase comparator to the error out (eo 1 and eo 0 ) pins. therefore, the relation among the outputs of the error out pins, divided frequency f n , and reference frequency f r are as follows. when reference frequency f r > divided frequency f n : low-level output when reference frequency f r < divided frequency f n : high-level output when reference frequency f r = divided frequency f n : floating output
m pd17016, 17017 170 14.5.4 unlock detection block as shown in figure 14-4, the unlock detection block detects the unlock status of the pll frequency synthesizer by using the up request or down request signal from the phase comparator. because either of the up request or down request signal outputs a low level in the unlock status, this low- level signal is used to detect the unlock status. in the unlock status, the unlock flip-flop (ff) is set to 1. the unlock status is detected by the pll unlock ff judgement register (refer to 14.5.5 ). the unlock ff is set at the cycle of reference frequency f r selected at that time. when the contents of the pll unlock ff judgement register are read (by the peek instruction), the unlock ff is reset (read & reset). therefore, the unlock ff must be detected at a cycle longer than the cycle 1/f r of the reference frequency f r . 14.5.5 configuration and function of unlock ff judgement register this register is a read-only register and is reset when its contents are read to the window register by the peek instruction. because the unlock ff is set at the cycle of reference frequency f r , the contents of the pll unlock ff judgement register must be written to the window register at a cycle longer than the cycle 1/f r of the reference frequency f r . name flag symbol b 3 0 b 2 0 b 1 0 b 0 p l l u l address 05h read/ write r & reset 0 1 detects status of unlock ff unlock ff = 0 : pll lock status unlock ff = 1 : pll unlock status power-on clock stop ce 0 0 0 undefined retained retained pll unlock ff judgement register fixed 0 on reset
m pd17016, 17017 171 14.6 pll disabled status the pll frequency synthesizer stops operation (is disabled) while the ce pin (pin 13) is low. when the pll is disabled by the pll reference mode select register, the pll frequency synthesizer also stops operation. table 14-2 shows the operation of each block under each pll disable condition. when the vcol and vcoh pins are disabled by the pll mode select register, only the vcol and vcoh pins are internally pulled down, and the other blocks operate. because the pll reference mode select register and pll mode select register are not initialized (but hold the previous status) on ce reset, they are restored to the original status when the ce pin has once gone low and then back high again after the pll has been disabled. to disable the pll on ce reset, therefore, initialize these registers in the program. the pll is disabled at power-on reset. table 14-2. operation of blocks under pll disable conditions condition ce pin = low level ce pin = high level (pll disabled) pll reference mode select register = 1111b pll mode select register = 0000b blocks (pll disabled) (vcoh, vcol disabled) vcol and internally pulled down internally pulled down internally pulled down vcoh pins programmable stops division stops division operates counter reference frequency stops output stops output operates generator phase comparator stops output stops output operates charge pump floats error out pins floats error out pins operates. however, usually outputs low level because there is no input. 14.7 using pll frequency synthesizer to control the pll frequency synthesizer, the following data are necessary. (1) division mode : direct division (mf), pulse swallow (hf, vhf) (2) pin used : vcol, vcoh (3) reference frequency: f r (4) division ratio : n the following subsections 14.7.1 through 14.7.3 explain how to set the pll data in each division mode (mf, hf, and vhf).
m pd17016, 17017 172 14.7.1 direct division mode (1) selecting division mode select the direct division mode by using the pll mode select register. (2) pin used when the direct division mode is selected, the vcol pin is enabled to operate. (3) setting reference frequency f r set the reference frequency by using the pll reference mode select register. (4) calculating division value n calculate as follows: f vcol n = f r where, f vcol : input frequency of vcol pin f r : reference frequency (5) example of setting pll data how to set the data to receive broadcasting in the following mw band is explained below. reception frequency : 1422 khz (mw band) reference frequency : 9 khz intermediate frequency: +450 khz division value n: f vcol 1422 + 450 n = = = 208 (decimal) f r 9 = 0d0h (hexadecimal) set data to the pll data register (pllr: peripheral address 41h), pll mode select register (rf address 21h), and pll reference mode select register (rf address 31h) as follows. pll data register (rllr) 0 0 0 0 0 1 1 0 1 d 0 0 0 0 0 dont care 0 0 0 1 mf 1 1 0 1 9 khz pll mode select register pll reference mode select register
m pd17016, 17017 173 14.7.2 pulse swallow mode (hf) (1) selecting division mode select the pulse swallow mode by using the pll mode select register. (2) pin used when the pulse swallow mode is selected, the vcol pin is enabled to operate. (3) setting reference frequency f r set the reference frequency by using the pll reference mode select register. (4) calculating division value n calculate as follows: f vcol n = f r where, f vcol : input frequency of vcol pin f r : reference frequency (5) example of setting pll data how to set the data to receive broadcasting in the following sw band is explained below. reception frequency : 25.50 mhz (sw band) reference frequency : 5 khz intermediate frequency: +450 khz division value n: f vcol 25500 + 450 n = = = 5190 (decimal) f r 5 = 1446h (hexadecimal) set data to the pll data register (pllr: peripheral address 41h), pll mode select register (rf address 21h), and pll reference mode select register (rf address 31h) as follows. pll data register (rllr) 0 0 0 1 1 0 1 0 0 4 0 1 0 0 4 0 1 1 0 6 0 0 1 1 hf 0 0 1 0 5 khz pll mode select register pll reference mode select register
m pd17016, 17017 174 14.7.3 pulse swallow mode (vhf) (1) selecting division mode select the pulse swallow mode by using the pll mode select register. (2) pin used when the pulse swallow mode is selected, the vcoh pin is enabled to operate. (3) setting reference frequency f r set the reference frequency by using the pll reference mode select register. (4) calculating division value n calculate as follows: f vcoh n = f r where, f vcoh : input frequency of vcoh pin f r : reference frequency (5) example of setting pll data how to set the data to receive broadcasting in the following fm band is explained below. reception frequency : 100.0 mhz (fm band) reference frequency : 25 khz intermediate frequency: +10.7 mhz division value n: f vcoh 100.0 + 10.7 n = = = 4428 (decimal) f r 0.025 = 114ch (hexadecimal) set data to the pll data register (pllr: peripheral address 41h), pll mode select register (rf address 21h), and pll reference mode select register (rf address 31h) as follows. pll data register (rllr) 0 0 0 1 1 0 0 0 1 1 0 1 0 0 4 1 1 1 0 c 0 0 1 0 vhf 0 1 1 0 25 khz pll mode select register pll reference mode select register
m pd17016, 17017 175 14.8 status on reset 14.8.1 on power-on reset the pll is disabled on power-on reset because the pll reference mode select register is initialized to 1111b. 14.8.2 on execution of clock stop instruction the pll is disabled when the ce pin goes low. 14.8.3 on ce reset (1) ce reset after execution of clock stop instruction the pll is disabled because the pll reference mode select register is initialized to 1111b by the clock stop instruction. (2) ce reset without clock stop instruction executed because the pll reference mode select register retains the previous status, the previous status is restored as soon as the ce pin has gone high. 14.8.4 in halt status the set status is retained if the ce pin is high.
m pd17016, 17017 176 15. general-purpose port the general-purpose ports output a high-level, low-level, or floating signal to an external circuit, and read a high-level or low-level signal from the external circuit. 15.1 configuration and classification of general-purpose ports figure 15-1 shows the block diagram of the general-purpose ports. table 15-1 classifies the general-purpose ports. as shown in figure 15-1, the general-purpose ports include ports 0a (p0a) through 2a (p2a) to which are set by addresses 70h through 73h (port registers) of each bank of the data memory, and ports 0e (p0e) and 0f (p0f) to which data are set by addresses 6bh and 6dh of bank 0 of the data memory. each port consists of general-purpose port pins (e.g., port 0a consists of p0a 3 through p0a 0 pins). as shown in table 15-1, the general-purpose ports are classified into input/output ports (i/o ports), input- only ports (input ports), and output-only ports (output ports). the i/o ports are further subdivided into bit i/o ports that can be set in the input or output mode in 1-bit units (1-pin units) and group i/o ports that can be set in the input or output mode in 4-bit units (4-pin units).
m pd17016, 17017 177 figure 15-1. block diagram of general-purpose port note bank3 is not provided on the m pd17016. system register bank3 note bank2 bank1 bank0 data memory column address 6b 6d setting of data bit i/o bit i/o group i/o in bit i/o out out in out 0 1 2 3 4 5 6 7 out out example of pin configuration of p0a setting of i/o port register control register 0123456789abcdef row address p 0 a p 0 b p 0 c p 0 d p 1 a p 1 b p 1 c p 1 d p 2 a p0a 3 pin p 0 e p 0 f p0a 2 pin p0a 1 pin p0a 0 pin
m pd17016, 17017 178 table 15-1. classification of general-purpose ports classification of general-purpose ports ports data set by: general-purpose ports i/o ports bit i/o port 0a port register port 0b port 0c group i/o port 0c port register input port port 0d port register port 1d output port port 1b port register port 1c port 2a port 0e port register port 0f (multiplexed with lcd segment register) 15.2 functional outline of general-purpose ports the general-purpose output ports and the general-purpose i/o ports set in the output mode output a high or low level from the corresponding pins when data are set to the corresponding port register or port group register. the general-purpose input ports and the general-purpose i/o ports set in the input mode detect the level of the signals input to the corresponding pins by reading the contents of the corresponding port register. the general-purpose i/o ports are set in the input or output mode by the corresponding control register. in other words, these ports can be set in the input or output mode by program. p0a through p0d, p1a through p1d, and p2a are set in the general-purpose port mode on power-on reset. p0e and p0f are used as lcd segment signal output pins on power-on reset. to use these ports as general- purpose output ports, the corresponding control registers must be set independently. the following subsections 15.2.1 through 15.2.4 explain the port registers, the function of the port group register, and the functional outline of each port.
m pd17016, 17017 179 15.2.1 general-purpose port data register (port register) a port register sets output data of and reads the input data of the corresponding general-purpose port. because the port registers are mapped on the data memory, they can be manipulated by any data memory manipulation instruction. figure 15-2 shows the relation between a port register and the corresponding port pins. by setting data to the port register corresponding to the port pins set in the general-purpose output port mode, the output of each pin is set. by reading the contents of the port register corresponding to the port pins set in the general-purpose input port mode, the input status of each pin is detected. table 15-2 shows the relation between each port (each pin) and port register. figure 15-2. relation between port register and pins reserved words are defined for the port registers by the assembler. because these reserved words are defined in flag (bit) units, the assembler embedded macro instructions can be used. note that data memory type reserved words are not defined for the port registers. p0e and p0f are multiplexed with lcd segment signal output pins. the port registers of p0e and p0f are also multiplexed with lcd segment registers. because the lcd segment registers are also mapped on the data memory, they can be treated in the same manner as the port registers. port register n m b 3 b 2 b 1 b 0 bit significance of port register address of port register (e.g., 70h = a, 71h = b, 72h = c, 73h = d) bank of port register p of port 3 2 1 0 bank address bit p p p p
m pd17016, 17017 180 15.2.2 general-purpose i/o ports (p0a, p0b, p0c, and p1a) p0a, p0b, p0c, and p1a can be set in the input or output mode by the p0a bit i/o select register (rf address 37h), p0b bit i/o select register (rf address 36h), p0c group i/o select register (rf address 27h), p1a bit i/o select register (rf address 35h), respectively. the input/output data of the p0a, p0b, p0c, and p1a are set by port registers p0a (address 70h of bank0), p0b (address 71h of bank0), p0c (address 72h of bank0), and p1a (address 70h of bank1), respectively. refer to table 15-2 . for details, refer to 15.3 . 15.2.3 general-purpose input ports (p0d and p1d) the input data of p0d and p1d are read by port registers p0d (address 73h of bank0) and p1d (address 73h of bank1), respectively. refer to table 15-2 . for details, refer to 15.4 . 15.2.4 general-purpose output ports (p1b, p1c, p2a, p0e, and p0f) (1) p1b, p1c, and p2a the output data of p1b, p1c, and p2a are set by port registers p1b (address 71h of bank1), p1c (address 72h of bank1), and p2a (address 70h of bank2). refer to table 15-2 . for details, refer to 15.5 . (2) p0e and p0f p0e and p0f usually operate as lcd segment signal output pins. these ports can be set in the output port mode by using a software macro supplied with the device file. to set the output data of p0e and p0f, p0e register (multiplexed with lcd segment register lcdd13, address 6dh of bank0) and p0f register (multiplexed with lcdd11, address 6bh of bank0) are used, respectively. refer to table 15-2 . for details, refer to 15.6 .
m pd17016, 17017 181 table 15-2. relation between each port (pin) and port register (1/2) port pin setting of data no. symbol i/o port register (data memory) remark bank address symbol bit symbol (reserved word) port 0a 3 p0a 3 i/o bank0 70h p0a b 3 p0a3 (p0a) 4 p0a 2 (bit i/o) b 2 p0a2 5 p0a 1 b 1 p0a1 6 p0a 0 b 0 p0a0 port 0b 7 p0b 3 i/o 71h p0b b 3 p0b3 (p0b) 8 p0b 2 (bit i/o) b 2 p0b2 9 p0b 1 b 1 p0b1 10 p0b 0 b 0 p0b0 port 0c 79 p0c 3 i/o 72h p0c b 3 p0c3 (p0c) 80 p0c 2 (group b 2 p0c2 1 p0c 1 i/o) b 1 p0c1 2 p0c 0 b 0 p0c0 poer 0d 75 p0d 3 input 73h p0d b 3 p0d3 (p0d) 76 p0d 2 b 2 p0d2 77 p0d 1 b 1 p0d1 78 p0d 0 b 0 p0d0 port 1a 14 p1a 3 i/o bank1 70h p1a b 3 p1a3 (p1a) 15 p1a 2 (bit i/o) b 2 p1a2 16 p1a 1 b 1 p1a1 17 p1a 0 b 0 p1a0 port 1b 18 p1b 3 output 71h p1b b 3 p1b3 (p1b) 19 p1b 2 b 2 p1b2 20 p1b 1 b 1 p1b1 21 p1b 0 b 0 p1b0 port 1c 22 p1c 3 output 72h p1c b 3 p1c3 (p1c) 23 p1c 2 b 2 p1c2 24 p1c 1 b 1 p1c1 25 p1c 0 b 0 p1c0 port 1d 26 p1d 3 input 73h p1d b 3 p1d3 (p1d) 27 p1d 2 b 2 p1d2 28 p1d 1 b 1 p1d1 29 p1d 0 b 0 p1d0 port 2a no target pins bank2 70h p2a b 3 p2a3 nothing is allocated. (p2a) b 2 p2a2 cannot be used as data b 1 p2a1 memory. 42 p2a 0 output b 0 p2a0 ----------------- ----------------- ----------------- ----------------- ----------------- ----------------- ----------------- ----------------- ----------------- ----------------- ----------------- ----------------- ----------------- ----------------- ----------------- ----------------- ----------------- ----------------- ----------------- ----------------- ----------------- ----------------- ----------------- ----------------- --------------- --------------- --------------- --------------- --------------- --------------- --------------- --------------- --------------- --------------- --------------- --------------- --------------- --------------- --------------- --------------- --------------- --------------- --------------- --------------- --------------- --------------- --------------- --------------- --------------- --------------- --------------------------- ------------------------------------------
m pd17016, 17017 182 table 15-2. relation between each port (pin) and port register (2/2) port pin setting of data no. symbol i/o port register (data memory) remark bank address symbol bit symbol (reserved word) bank2 71h C b 3 C nothing is allocated. b 2 cannot be used as data b 1 memory. b 0 72h C b 3 C b 2 b 1 b 0 73h C b 3 C b 2 b 1 b 0 bank3 note 70h C b 3 C nothing is allocated. b 2 cannot be used as data b 1 memory. b 0 71h C b 3 C b 2 b 1 b 0 72h C b 3 C b 2 b 1 b 0 73h C b 3 C b 2 b 1 b 0 port 0e 49 p0e 3 output bank0 6bh p0e b 3 p0e3 (p0e) 50 p0e 2 (multiplexed b 2 p0e2 51 p0e 1 with lcdd11) b 1 p0e1 52 p0e 0 b 0 p0e0 port 0f 45 p0f 3 output 6dh p0f b 3 p0f3 (p0f) 46 p0f 2 (multiplexed b 2 p0f2 47 p0f 1 with lcdd13) b 1 p0f1 48 p0f 0 b 0 p0f0 note bank3 is not provided on the m pd17016. ----------------- ----------------- ----------------- ----------------- ----------------- ----------------- --------------- --------------- --------------- --------------- --------------- ---------------
m pd17016, 17017 183 15.3 general-purpose i/o ports (p0a, p0b, p0c, and p1a) 15.3.1 configuration of i/o ports the following paragraphs (1) through (3) indicate the configuration of the i/o ports. (1) p0a (p0a 1 and p0a 0 pins), p0b (p0b 3 , p0b 2 , p0b 1 , and p0b 0 pins), p1a (p1a 3 , p1a 2 , p1a 1 , and p1a 0 pins) (2) p0c (p0c 3 , p0c 2 , p0c 1 , and p0c 0 pins) v dd v dd i/o select flag output latch 1 0 read instruction port register (1 bit) write instruction reset v dd v dd i/o select flag output latch 1 0 read instruction port register (1 bit) write instruction
m pd17016, 17017 184 (3) p0a (p0a 3 and p0a 2 pins) 15.3.2 using i/o ports the i/o ports are set in the input or output mode by i/o select registers p0a p0b, p0c, and p1a of the control registers. the bit i/o ports (p0a, p0b, and p1a) can be set in the input or output mode in 1-bit units, and group i/o port (p0c) can be set in the input or output mode in 4-bit units. output data can be set to a port by writing the data to the corresponding port register, and the input data of the port can be read by executing an instruction that reads the port register. 15.3.3 explains the i/o select register of each port. 15.3.4 and 15.3.5 explain how to use the input and output ports. 15.3.6 explains the points to be noted in using the i/o ports. v dd i/o select flag output latch read instruction port register (1 bit) write instruction reset
m pd17016, 17017 185 15.3.3 port 0a bit i/o select register port 0b bit i/o select register port 1a bit i/o select register port 0c group i/o select register the port 0a bit i/o, port 0b bit i/o, port 1a bit i/o, and port 0c group i/o select registers sets each pin of the p0a, p0b, p1a, and p0c in the input or output mode. the configuration and functions of these registers are shown below. (1) port 0a bit i/o select register name flag symbol b 3 b 2 b 1 b 0 address 37h read/ write r/w 0 1 sets input or output mode of port sets p0a 0 pin in input mode. sets p0a 0 pin in output mode. power-on clock stop ce 0 0 0 0 0 0 0 0 0 0 0 0 port 0a bit i/o select register sets input or output mode of port sets p0a 1 pin in input mode. sets p0a 1 pin in output mode. sets input or output mode of port sets p0a 2 pin in input mode. sets p0a 2 pin in output mode. sets input or output mode of port sets p0a 3 pin in input mode. sets p0a 3 pin in output mode. 0 1 0 1 0 1 p 0 a b i o 3 p 0 a b i o 2 p 0 a b i o 1 p 0 a b i o 0 on reset
m pd17016, 17017 186 (2) port 0b bit i/o select register name flag symbol b 3 b 2 b 1 b 0 address 36h read/ write r/w 0 1 sets input or output mode of port sets p0b 0 pin in input mode. sets p0b 0 pin in output mode. power-on clock stop ce 0 0 0 0 0 0 0 0 0 0 0 0 port 0b bit i/o select register sets input or output mode of port sets p0b 1 pin in input mode. sets p0b 1 pin in output mode. sets input or output mode of port sets p0b 2 pin in input mode. sets p0b 2 pin in output mode. sets input or output mode of port sets p0b 3 pin in input mode. sets p0b 3 pin in output mode. 0 1 0 1 0 1 on reset p 0 b b i o 3 p 0 b b i o 2 p 0 b b i o 1 p 0 b b i o 0
m pd17016, 17017 187 (3) port 1a bit i/o select register name flag symbol b 3 b 2 b 1 b 0 address 35h read/ write r/w 0 1 sets input or output mode of port sets p1a 0 pin in input mode. sets p1a 0 pin in output mode. power-on clock stop ce 0 0 0 0 0 0 0 0 0 0 0 0 port 1a bit i/o select register sets input or output mode of port sets p1a 1 pin in input mode. sets p1a 1 pin in output mode. sets input or output mode of port sets p1a 2 pin in input mode. sets p1a 2 pin in output mode. sets input or output mode of port sets p1a 3 pin in input mode. sets p1a 3 pin in output mode. 0 1 0 1 0 1 p 1 a b i o 3 p 1 a b i o 2 p 1 a b i o 1 p 1 a b i o 0 on reset
m pd17016, 17017 188 (4) port 0c group i/o select register name flag symbol b 3 0 b 2 0 b 1 0 b 0 p 0 c g i o address 27h read/ write r/w 0 1 sets input or output mode of port sets p0c 3 -p0c 0 pin in input mode. sets p0c 3 -p0c 0 pin in output mode. power-on clock stop ce 0000 0 0 port 0c group i/o select register fixed to 0 on reset
m pd17016, 17017 189 15.3.4 using i/o ports (p0a, p0b, p0c, and p1a) as input ports select the pin that is used as an input port pin by the i/o select register corresponding to each port. note that p0c can be set in the input or output mode in 4-bit units only. the pin specified as an input port pin is floated (hi-z), and waits for input of an external signal. the input data can be read by executing an instruction that reads the contents of the port register corresponding to each port, such as skt instruction. when a high level is input to each pin, 1 is read to the corresponding port register; when a low level is input, 0 is read. if a write instruction, such as mov, is executed to the port register corresponding to the port pin specified as an input port pin, the contents of the output latch are rewritten. 15.3.5 using i/o ports (p0a, p0b, p0c, and p1a) as output ports select the pin that is used as an output port pin by the i/o select register corresponding to each port. note that p0c can be set in the input or output mode in 4-bit units only. the pin specified as an output port pin outputs the contents of the output latch. the output data can be set by executing an instruction that writes the contents of the corresponding port register to each pin, such as mov instruction. to output a high level to each pin, write 1 to the corresponding port register; to output a low level, write 0. the port pin can also be floated when it is specified as an input port pin. when an instruction, such as skt, that reads the contents of the port register corresponding to a port specified as an output port is executed, the contents of the output latch are read. note, however, that the statuses of the p0a 3 and p0a 2 pins are read as is, and the read contents may be different from the contents of the output latch. refer to 15.3.6 .
m pd17016, 17017 190 15.3.6 notes on using i/o ports (p0a 3 and p0a 2 pins) when using the p0a 3 and p0a 2 pins as output pins, the contents of the output latch may be rewritten, as shown in the example below. example to specify p0a 3 and p0a 2 pins as output port pins initflg p0abi03, p0abi02, not p0abi01, not p0abi00 ; sets p0a 3 and p0a 2 pins in output mode initflg p0a3, p0a2, not p0a1, not p0a0 ; outputs high level to p0a 3 and p0a 2 pins ;<1> clr1 p0a3 ; outputs low level to p0a 3 pin macro expansion and . mf. p0a3 shr 4, # .df. (not p0a3 and 0fh) if the p0a 2 pin happens to be lowered by an external device when the instruction in <1> above is executed, the contents of the output latch of the p0a 2 pin are rewritten to 0 by the clr1 instruction. in other words, if an operation instruction (such as add and or) to the p0a port register when the p0a 3 or p0a 2 pin is set in the output mode, the contents of the output latch are rewritten to the current level of the pin, regardless of the previous status of the pin. 15.3.7 status of i/o ports (p0a, p0b, p0c, and p1a) on reset (1) on power-on reset all the i/o ports are set in the input mode. because the contents of the output latch are undefined, the output latch must be initialized by program, as necessary, before setting the corresponding port in the output mode. (2) on ce reset all the i/o ports are set in the input mode. the contents of the output latch are retained. (3) on execution of clock stop instruction all the i/o ports are set in the input mode. the contents of the output latch are retained. the i/o ports other than p0c prevents an increase in the current dissipation due to the noise of the input buffer by using the reset signal when the clock stop instruction is executed, as explained in 15.3.1. if p0c is floated on execution of the clock stop instruction, the current dissipation may increase due to external noise. externally pull this port down or up as necessary. (4) in halt status the previous status is retained.
m pd17016, 17017 191 15.4 general-purpose input ports (p0d and p1d) 15.4.1 configuration of input ports the following paragraphs (1) and (2) indicate the configuration of the input ports. (1) p0d (p0d 3 , p0d 2 , p0d 1 , and p0d 0 pins) (2) p1d (p1d 3 , p1d 2 , p1d 1 , and p1d 0 pins) v dd high on resistance to a/d converter write instruction read instruction port register (1 bit) input latch adc select signal key source signal timing output reset v dd to frequency counter or a/d converter write instruction read instruction port register (1 bit) reset
m pd17016, 17017 192 15.4.2 using input ports (p0d and p1d) the input data is read by executing an instruction, such as skt, that reads the contents of the port register corresponding to each port pin. when a high level is input to each pin, 1 is read to the corresponding port register; when a low level is input, 0 is read. nothing is changed even if a write instruction, such as mov, is executed to the port register. 15.4.3 notes on using input port (p0d) the p0d is internally pulled down when it is used as a general-purpose port. 15.4.4 status of input ports (p0d and p1d) on reset (1) on power-on reset all the input ports are specified as general-purpose input ports. (2) on ce reset all the input ports are specified as general-purpose input ports. (3) on execution of clock stop instruction all the input ports are specified as general-purpose input ports. because the reset signal is output when the clock stop instruction is executed, the p1d prevents an increase in the current dissipation due to the noise of the input buffer. the p0d is internally pulled down. (4) in halt status the previous status is retained.
m pd17016, 17017 193 15.5 general-purpose output ports (p1b, p1c, and p2a) 15.5.1 configuration of output ports (p1b, p1c, and p2a) the following paragraphs (1) and (2) indicate the configuration of the output ports. (1) p1b (p1b 0 pin), p1c (p1c 3 , p1c 2 , p1c 1 , and p1c 0 pins), p2a (p2a 0 pin) (2) p1b (p1b 3 , p1b 2 , and p1b 1 pins) v dd output latch read instruction port register (1 bit) write instruction output latch read instruction port register (1 bit) write instruction
m pd17016, 17017 194 15.5.2 example of using output ports (p1b, p1c, and p2a) the output ports output the contents of the output latches. the output data is set by executing an instruction, such as mov, that writes the data to the port register corresponding to the output port. write 1 to the port register to output a high level to the corresponding port; write 0 to output a low level. note, however, that the p1b 3 , p1b 2 , and p1b 1 pins are n-ch open-drain output pins and are floated when a high level is output. when an instruction, such as skt, that reads the contents of the port register is read, the contents of the output latch are read. 15.5.3 status of output ports (p1b, p1c, and p2a) on reset (1) on power-on reset the contents of the output latch are output. because the contents of the output latch are undefined, an undefined value is output for a fixed period (until the output latch is initialized by program). (2) on ce reset the contents of the output latch are output. the contents of the output latch are retained and the output data are not changed on ce reset. (3) on execution of clock stop instruction the contents of the output latch are output. the contents of the output latch are retained and the output data are not changed on execution of the clock stop instruction. therefore, initialize the output latch in the program as necessary. (4) in halt status the contents of the output latch are output. the contents of the output latch are retained and the output data are not changed in the halt status.
m pd17016, 17017 195 15.6 general-purpose output ports (p0e and p0f) 15.6.1 configuration of output ports (p0e and p0f) the configuration of the output ports is shown below. p0e (p0e 3 , p0e 2 , p0e 1 , and p0e 0 pins) p0f (p0f 3 , p0f 2 , p0f 1 , and p0f 0 pins) 15.6.2 example of using output ports (p0e and p0f) each pin of the p0e and p0f are used as an lcd segment signal output pin on power-on reset. to use it as an output port pin, select the port to be used by a software macro supplied with the device file. the port to be used can be selected independently. the pins not set in the output port mode can be used as lcd segment signal output pins. table 15-3 shows the software macros that set the ports (p0e and p0f). v dd 1 0 lcd/port select flag segment signal timing control output latch write instruction read instruction port register (1 bit) multiplexed with lcd segment register
m pd17016, 17017 196 table 15-3. software macros setting ports (p0e and p0f) function macro format uses lcd 22 /p0e 0 -lcd 25 /p0e 3 pins as general-purpose output port set1_p0eon uses lcd 26 /p0f 0 -lcd 29 /p0f 3 pins as general-purpose output port set1_p0fon uses lcd 22 /p0e 0 -lcd 25 /p0e 3 pins and lcd 26 /p0f 0 -lcd 29 /p0f 3 pins as general-purpose set2_p0eon_p0fon output port uses lcd 22 /p0e 0 -lcd 25 /p0e 3 pins as lcd segment signal output pins clr1_p0eon uses lcd 26 /p0f 0 -lcd 29 /p0f 3 pins as lcd segment signal output pins clr1_p0fon uses lcd 22 /p0e 0 -lcd 25 /p0e 3 and lcd 26 /p0f 0 -lcd 29 /p0f 3 pins as lcd segment signal clr2_p0eon_p0fon output pins uses lcd 22 /p0e 0 -lcd 25 /p0e 3 pins as lcd segment signal output pins and lcd 26 / p0f 0 - init_not_p0eon_p0fon lcd 29 /p0f 3 pins as general-purpose output port uses lcd 22 /p0e 0 -lcd 25 /p0e 3 pins as general-purpose output port and lcd 26 /p0f 0 -lcd 29 / init_p0eon_not_p0fon p0f 3 pins as lcd segment signal output pins caution if the above macros are used, the contents of the window register are destroyed. if the above macros are immediately follow an embedded macro instruction, an object error occurs when the source file is assembled and loaded to the in-circuit emulator. if an embedded macro is used before the above macros, insert a comment statement in between them. 15.6.3 setting data to p0e and p0f output data are set to the p0e and p0f by executing an instruction, such as mov, that writes data to the port registers corresponding to the ports. to output a high level to each port pin, write 1 to the corresponding port register; to output a low level, write 0. the contents of the output latch are read when an instruction, such as skt, that reads the contents of the port register is executed. figure 15-3 shows the relation between the p0f port register and lcd segment register. as shown in this figure, lcd segment register lcdd14 can be used as a general-purpose data memory area when the p0f is used. the same applies to the p0e. refer to figure 21-6. relation among lcd display dots, ports 0e and 0f, key source output, and each data setting register in 21. lcd controller/driver . figure 15-3. relation between p0f port register and lcd segment register p0fon flag lcd 29 /p0f 3 1 0 segment signal timing control lcdd14 (6eh) b 3 lcd 28 /p0f 2 1 0 segment signal timing control b 1 lcd 27 /p0f 1 1 0 segment signal timing control b 3 lcd 26 /p0f 0 1 0 segment signal timing control b 1 b 2 b 0 b 0 b 2 lcdd13 p0f (6dh)
m pd17016, 17017 197 15.6.4 status of output ports (p0e and p0f) on reset (1) on power-on reset the p0e and p0f are set as lcd segment signal output pins and output a low level. because the contents of the output latch are undefined, undefined data is output if these ports are set in the output mode as is. initialize the ports in the program as necessary. (2) on ce reset the p0e and p0f are set as lcd segment signal output pins and output a low level. because the contents of the output latch are retained, the previous values are retained if these ports are set in the output mode as is. (3) on execution of clock stop instruction the p0e and p0f are set as lcd segment signal output pins and output a low level. because the contents of the output latch are retained, the previous values are retained if these ports are set in the output mode as is. (4) in halt status the contents of the output latch are output. because the contents of the output latch are retained, the output data are not changed in the halt status.
m pd17016, 17017 198 16. a/d converter (adc) the a/d converter is used to input an external analog signal as a digital signal. 16.1 configuration of a/d converter figure 16-1 shows the block diagram of the a/d converter. as shown in the figure, the a/d converter consists of an input select block, compare voltage generation block, and compare block. figure 16-1. block diagram of a/d converter 16.2 functional outline of a/d converter the a/d converter compares the voltage input to the p0d 3 /adc 5 to p1d 0 /adc 0 pin with an internal compare voltage, and outputs the result of the comparison as true (1) or false (0). by judging this comparison result by software, the a/d converter can be used as a successive approximation converter. the following subsections 16.2.1 through 16.2.3 outline the function of each block of the a/d converter. for details, refer to 16.3 through 16.5 . 16.2.1 input select block this block selects which of the p0d 3 /adc 5 through p1d 0 /adc 0 pins is to be used. the pin is selected by the a/d converter channel select register (rf address 14h). only one pin can be selected at a time. refer to 16.3 . 16.2.2 compare voltage generation block this block generates a compare voltage against which an input voltage is to be compared. the compare voltage is generated by an r-string d/a converter. refer to 16.4 . input select block control register data buffer compare block compare voltage generation block (r-string d/a converter) 6 p0d 3 /adc 5 p0d 2 /adc 4 p0d 1 /adc 3 p0d 0 /adc 2 p1d 1 /adc 1 p1d 0 /adc 0
m pd17016, 17017 199 16.2.3 compare block this block compares an input voltage with an internal compare voltage. the result of the comparison is detected by the a/d converter compare judge register (rf address 06h). refer to 16.5 . 16.3 input select block 16.3.1 configuration of input select block figure 16-2 shows the configuration of the input select block. figure 16-2. configuration of input select block address bit flag symbol control register 14h b 3 b 2 b 1 b 0 3-6 decoder to compare block v adcin 0 1 p0d 3 /adc 5 p0d 2 /adc 4 p0d 1 /adc 3 p0d 0 /adc 2 p1d 1 /adc 1 p1d 0 /adc 0 high on resistance (for key input) a d c c h 3 a d c c h 2 a d c c h 1 a d c c h 0
m pd17016, 17017 200 16.3.2 function of input select block the input select block selects a pin to be used by using the a/d converter channel select register. only one pin can be used as an a/d converter pin at a time. the pin not selected for the a/d converter can be used as general-purpose input port. although port 0d (p0d 3 /adc 5 through p0d 0 /adc 2 pins) is internally connected to a pull-down resistor, the pin selected by the a/d converter channel select register (refer to 16.3.3 ) is disconnected from the pull-down resistor as soon as it has been selected. the pins not selected remain connected to the pull-down resistor. 16.3.3 configuration and function of a/d converter channel select register the a/d converter channel select register selects a pin to be used for the a/d converter. the configuration and function of this register are shown below. name flag symbol b 3 b 2 b 1 b 0 address 14h read/ write r/w 0 1 0 1 0 1 0 1 selects pin to be used for a/d converter p1d 0 /adc 0 pin p1d 1 /adc 1 pin p0d 0 /adc 2 pin p0d 1 /adc 3 pin p0d 2 /adc 4 pin p0d 3 /adc 5 pin a/d converter is not used (general-purpose input port) a/d converter is not used (general-purpose input port) power-on clock stop ce 01 1 1 1 1 1 1 1 1 a/d converter channel select register fixed to 0 0 0 1 1 0 0 1 1 0 0 0 0 1 1 1 1 a d c c h 3 a d c c h 2 a d c c h 1 a d c c h 0 on reset
m pd17016, 17017 201 16.4 compare voltage generation block 16.4.1 configuration of compare voltage generator block figure 16-3 shows the configuration of the compare voltage generator block. figure 16-3. configuration of compare voltage generator block 16.4.2 function of compare voltage generator block the compare voltage generator block switches the multiplexer according to the 6-bit data set to the a/d converter data register (adcr: peripheral address 02h) and generates a compare voltage. this block is therefore an r-string d/a converter. the compare voltage can be adjusted in 64 steps by the r string (resistance division). the voltage supplied to the r string is the same as the supply voltage v dd of the device. the voltage is supplied to the resistor of the r string only when the a/d converter compare judge register, which is to be explained later, is detected. the compare voltage is compared with a voltage input to the compare block from a selected pin. 16.4.3 explains the configuration and function of the a/d converter data register. table 16-1 lists the compare voltages. data buffer (dbf) address symbol data 0ch dbf3 dont care 0dh dbf2 dont care 0eh dbf1 0fh dbf0 6 peripheral address 02h a/d converter data register multiplexer 01 2 6263 to compare block v ref v dd 1 2 rr r 3 2 r reading adccmp flag by peek m s b l s b
m pd17016, 17017 202 16.4.3 configuration and function of a/d converter data register (adcr) the a/d converter data register sets the compare voltage of the a/d converter. because this register is 6 bits long, the low-order 6 bits of the data buffer are valid. name symbol address bit data data buffer dbf3 0ch dont care dbf2 0dh dont care dbf1 0eh dbf0 0fh b 3 b 2 b 1 b 0 b 3 b 2 b 1 b 0 b 3 b 2 b 1 b 0 b 3 b 2 b 1 b 0 transfer data 8 get can be executed put can be executed b 7 0 b 6 0 b 5 b 4 b 3 b 2 b 1 b 0 name a/d converter data register peripheral register symbol adcr valid data 02h peripheral hardware a/d converter sets compare voltage v ref of a/d converter 0 1 x 63 v ref = 0 v v ref = v dd v x C 0.5 64 fixed to 0 peripheral address
m pd17016, 17017 203 table 16-1. set values of a/d converter data register and compare voltages set data of adcr compare voltage set data of adcr compare voltage decimal hexadecimal logic voltage at v dd = 5 v decimal hexadecimal logic voltage at v dd = 5 v (dec) (hex) unit: v dd v unit: v (dec) (hex) unit: v dd v unit: v 0 00h 0 0 32 20h 31.5/64 2.461 1 01h 0.5/64 0.039 33 21h 32.5/64 2.539 2 02h 1.5/64 0.117 34 22h 33.5/64 2.617 3 03h 2.5/64 0.195 35 23h 34.5/64 2.695 4 04h 3.5/64 0.273 36 24h 35.5/64 2.773 5 05h 4.5/64 0.352 37 25h 36.5/64 2.852 6 06h 5.5/64 0.430 38 26h 37.5/64 2.930 7 07h 6.5/64 0.508 39 27h 38.5/64 3.008 8 08h 7.5/64 0.586 40 28h 39.5/64 3.086 9 09h 8.5/64 0.664 41 29h 40.5/64 3.164 10 0ah 9.5/64 0.742 42 2ah 41.5/64 3.242 11 0bh 10.5/64 0.820 43 2bh 42.5/64 3.320 12 0ch 11.5/64 0.898 44 2ch 43.5/64 3.398 13 0dh 12.5/64 0.977 45 2dh 44.5/64 3.477 14 0eh 13.5/64 1.055 46 2eh 45.5/64 3.555 15 0fh 14.5/64 1.133 47 2fh 46.5/64 3.633 16 10h 15.5/64 1.211 48 30h 47.5/64 3.711 17 11h 16.5/64 1.289 49 31h 48.5/64 3.789 18 12h 17.5/64 1.367 50 32h 49.5/64 3.867 19 13h 18.5/64 1.445 51 33h 50.5/64 3.945 20 14h 19.5/64 1.523 52 34h 51.5/64 4.023 21 15h 20.5/64 1.602 53 35h 52.5/64 4.102 22 16h 21.5/64 1.680 54 36h 53.5/64 4.180 23 17h 22.5/64 1.758 55 37h 54.5/64 4.258 24 18h 23.5/64 1.836 56 38h 55.5/64 4.336 25 19h 24.5/64 1.914 57 39h 56.5/64 4.414 26 1ah 25.5/64 1.992 58 3ah 57.5/64 4.492 27 1bh 26.5/64 2.070 59 3bh 58.5/64 4.570 28 1ch 27.5/64 2.148 60 3ch 59.5/64 4.648 29 1dh 28.5/64 2.227 61 3dh 60.5/64 4.727 30 1eh 29.5/64 2.305 62 3eh 61.5/64 4.805 31 1fh 30.5/64 2.383 63 3fh 62.5/64 4.883
m pd17016, 17017 204 16.5 compare block 16.5.1 configuration of compare block figure 16-4 shows the configuration of the compare block. figure 16-4. configuration of compare block 16.5.2 function of compare block the compare block compares the voltage v adcin input from a pin with the internal compare voltage v ref by using a comparator and outputs the result of the comparison to the compare judge ff. the compare judge ff can be detected by reading the adccmp flag of the a/d converter compare judge register. the adccmp flag is set when v adcin > v ref and reset when v adcin < v ref . the comparator performs comparison when the adccmp flag has been read. in other words, when the adccmp flag has been read by using the peek instruction, comparison is performed by manipulating switches 1 and 2. therefore, the time required for the a/d converter to perform comparison once is equal to one instruction execution time (4.44 m s). 16.5.3 explains the configuration and function of the a/d converter compare judge register. address bit flag symbol control register 06h b 3 0 b 2 0 b 1 0 b 0 a d c c m p compare judge ff comparator + C 2 pf 1 2 v dd switch 2 switch 1 v adcin v ref
m pd17016, 17017 205 16.5.3 configuration and function of a/d converter compare judge register the a/d converter compare judge register detects the result of comparison between input voltage v adcin and compare voltage v ref . the configuration and function of this register are illustrated below. 16.6 performances of a/d converter the performances of the a/d converter are as follows. parameter performance resolution 1lsb input voltage range 0-v dd quantization error over range error of offset, gain, and non-linearity note including quantization error. 1 lsb 2 62.5 v dd 64 3 lsb note 2 name flag symbol b 3 0 b 2 0 b 1 0 b 0 a d c c m p address 06h read/ write r 0 1 detects result of comparison by a/d converter v adcin < v ref v adcin > v ref a/d converter compare judge register fixed to 0 power-on clock stop ce 0 0 0 undefined retained retained on reset
m pd17016, 17017 206 16.7 using a/d converter 16.7.1 comparing one compare voltage here is a program example. example to compare input voltage v adcin of adc 0 pin with compare voltage v ref (31.5/64 v dd ) and branch to aaa if v adcin > v ref or to bbb if v adcin < v ref init: adcr7 flg 0.0eh.3 ; dummy adcr6 flg 0.0eh.2 ; dummy adcr5 flg 0.0eh.1 ; defines each bit of data buffer as adcr data setting adcr4 flg 0.0eh.0 ; flag adcr3 flg 0.0fh.3 adcr2 flg 0.0fh.2 adcr1 flg 0.0fh.1 adcr0 flg 0.0fh.0 clr3 adcch2, adcch1, adcch0 ; sets p1d 0 /adc 0 pin for the a/d converter start: initflg not adcr3, not adcr2, not adcr1, not adcr0 initflg not adcr7, not adcr6, adcr5, not adcr4 put adcr, dbf ; sets compare voltage v ref to 31.5/64 v dd skt1 adccmp ; detects adccmp flag, and br aaa ; branches to aaa if false (0) br bbb ; branches to bbb if true (1)
m pd17016, 17017 207 16.7.2 successive approximation by binary search method the a/d converter can compare only one voltage at one time. to convert an input voltage into a digital signal, therefore, successive approximation must be executed by program. if the processing time of the successive approximation program differs depending on the input voltage, the relation with the other processing programs is undesirable. therefore, use of the binary search method as explained in (1) through (3) below is recommended. (1) concept of binary search the concept of binary search is explained below. first, the compare voltage is set to 1/2 v dd . if the result of comparison is true (a high level is input), a voltage of 1/4 v dd is added to the result; if the result of comparison is false (a low level is input), a voltage of 1/4 v dd is subtracted from the result and compared. subsequently, the compare voltage is sequentially compared with 1/8 v dd and 1/16 v dd to 1/64 v dd . if the result of comparison is false after comparison has been executed six times, 1/64 v dd is subtracted from the result and comparison is completed. compare voltage ( v dd ) h l h l 1/2 3/4 1/4 7/8 5/8 h l h l 11/16 9/16 h l 3/8 1/8 h l h l 1/16 0 h l 15/16 h l 63/64 61/64 h l 59/64 h l h l h l 13/16 31/32 29/32 27/32 25/32 57/64 55/64 53/64 51/64 49/64 1 1 l 63/64 62/64 l 61/64 60/64 l 59/64 58/64 l 57/64 56/64 l 55/64 54/64 l 53/64 52/64 l 51/64 50/64 l 49/64 48/64 subtracts 1/64 if false 7/16 5/16 3/16 15/16 13/16 first time second time third time fourth time fifth time sixth time
m pd17016, 17017 208 (2) flowchart of binary search method start initialization : sets pin to be used adcr 100000b : sets compare voltage to 1/2 v dd end adccmp = 1? y n resets b 5 of adcr : if result is 0, subtracts 1/2 v dd : detects result of comparison sets b 4 of adcr : adds 1/4 v dd to result to set compare voltage regardless of whether result is 0 or 1 y n : detects result of comparison resets b 4 of adcr : if result is 0, subtracts 1/4 v dd sets b 3 of adcr : adds 1/8 v dd to result to set compare voltage regardless of whether result is 0 or 1 adccmp = 1? y n : detects result of comparison resets b 3 of adcr : subtracts 1/8 v dd if result is 0 sets b 2 of adcr : adds 1/16 v dd to result to set compare voltage regardless of whether result is 0 or 1 adccmp = 1? y n : detects result of comparison resets b 2 of adcr : subtracts 1/16 v dd if result is 0 sets b 1 of adcr : adds 1/32 v dd to result to set compare voltage regardless of whether result is 0 or 1 adccmp = 1? y n : detects result of comparison resets b 1 of adcr : subtracts 1/32 v dd if result is 0 sets b 0 of adcr : adds 1/64 v dd to result to set compare voltage regardless of whether result is 0 or 1 adccmp = 1? y n : detects result of comparison resets b 0 of adcr : subtracts 1/64 v dd if result is 0 detects contents of adcr : completes conversion with current value if result is 1 adccmp = 1?
m pd17016, 17017 209 (3) program example of binary search method (a) method with short conversion time init: adcr7 flg 0.0eh.3 ; dummy adcr6 flg 0.0eh.2 ; dummy adcr5 flg 0.0eh.1 ; defines each bit of data buffer as adcr data setting flag adcr4 flg 0.0eh.0 adcr3 flg 0.0fh.3 adcr2 flg 0.0fh.2 adcr1 flg 0.0fh.1 adcr0 flg 0.0fh.0 clr3 adcch2, adcch1, adcch0 ; sets p1d 0 /adc 0 pin for the a/d converter start: initflg not adcr3, not adcr2, not adcr1, not adcr0 initflg not adcr7, not adcr6, adcr5, not adcr4 put adcr, dbf ; sets compare voltage to 31.5/64 v dd skt1 adccmp ; detects adccmp and subtracts clr1 adcr5 ; 32/64 v dd if 0 and adds set1 adcr4 ; 16/64 v dd put adcr, dbf skt1 adccmp ; detects adccmp and subtracts clr1 adcr4 ; 16/64 v dd if 0 and adds set1 adcr3 ; 8/64 v dd put adcr, dbf skt1 adccmp ; detects adccmp and subtracts clr1 adcr3 ; 8/64 v dd if 0 and adds a/d conversion set1 adcr2 ; 4/64 v dd put adcr, dbf skt1 adccmp ; detects adccmp and subtracts clr1 adcr2 ; 4/64 v dd if 0 and adds set1 adcr1 ; 2/64 v dd put adcr, dbf skt1 adccmp ; detects adccmp and subtracts clr1 adcr1 ; 2/64 v dd if 0 and adds set1 adcr0 ; 1/64 v dd put adcr, dbf skt1 adccmp ; detects adccmp and subtracts clr1 adcr0 ; 1/64 v dd if 0 end: number of program steps : 31 steps number of execution steps: 31 steps a/d conversion time : 137.8 m s
m pd17016, 17017 210 (b) method with fewer program steps adwork1 mem 0.00h ; work area for changing compare voltage adwork0 mem 0.01h initflg not adcch2, not adcch1, not adcch0 ; sets p1d 0 /adc 0 pin for the a/d converter start: mov dbf1, #0010b ; sets compare voltage to initial value of 31.5/64 v dd mov dbf0, #0000b mov adwork1, #0001b mov adwork0, #0000b ad_check: put adcr, dbf ; sets compare voltage v ref skt1 adccmp ; detects adccmp flag br adin_l add dbf0, adwork0 ; increases compare voltage if 1 addc dbf1, adwork1 br next_ad a/d adin_l: conversion sub dbf0, adwork0 ; decreases compare voltage if 0 subc dbf1, adwork1 ; nop ; described to keep a/d conversion time constant next_ad: rorc adwork1 rorc adwork0 skt1 cy ; 6 bits completed? br ad_check put adcr, dbf skt1 adccmp and dbf0, #1110b . . . number of program steps : 22 steps number of execution steps: 58 to 63 steps a/d conversion time : 257.8 to 280 m s where the a/d conversion time is held constant number of program steps : 23 steps number of execution steps: 63 steps a/d conversion time : 280 m s
m pd17016, 17017 211 16.8 notes on using a/d converter when the p0d 3 /adc 5 to p0d 0 /adc 2 pin is used for the a/d converter and if it is specified that the halt status can be released by key input, the halt status may not be set. this happens because, as explained in 12.4 halt function, the pin selected for the a/d converter is disconnected from the latch of the input port. figure 16-5 shows the relation between the p0d 3 /adc 5 through p0d 0 /adc 2 pins and input latch. as shown in this figure, if a high level is input to the input pin when the a/d converter is set by the a/d converter select signal, the status 1 of input latch is retained. even if an attempt is made to set the state where the halt status is released by key input at this time, therefore, since a high level is being input to this pin, the halt status is immediately released. figure 16-5. relation between p0d 3 /adc 5 through p0d 0 /adc 2 pins and input latch 16.9 status on reset 16.9.1 on power-on reset all the p0d 3 /adc 5 through p0d 0 /adc 2 pins, p1d 1 /adc 1 , and p1d 0 /adc 0 pins are set in the general-purpose input port mode. 16.9.2 on execution of clock stop instruction all the p0d 3 /adc 5 through p0d 0 /adc 2 pins, p1d 1 /adc 1 , and p1d 0 /adc 0 pins are set in the general-purpose input port mode. 16.9.3 on ce reset all the p0d 3 /adc 5 through p0d 0 /adc 2 pins, p1d 1 /adc 1 , and p1d 0 /adc 0 pins are set in the general-purpose input port mode. v dd p0d n /adc m to a/d converter to port register input latch a/d converter select signal
m pd17016, 17017 212 17. d/a converter (dac) the d/a converter (dac) outputs its signal by means of pwm (pulse width modulation) that varies the duty factor. by connecting an external lowpass filter to the d/a converter, digital signals can be converted into analog signals. 17.1 configuration of d/a converter figure 17-1 shows the block diagram of the d/a converter. as shown in the figure, the d/a converter consists of an output select block and a duty setting block for each pin, and a clock generation block. figure 17-1. block diagram of d/a converter 17.2 functional outline of d/a converter the d/a converter outputs a variable-duty signal to each output pin. the output frequency is 878.9 hz, and the duty factor can be changed in 256 steps. the following subsections 17.2.1 through 17.2.3 outlines the function of each block of the d/a converter. 17.2.1 output select blocks the output select blocks specify whether each pin is used as a general-purpose output port pin or a d/a converter pin. the mode of each pin is selected by the pwm pin setting software macro supplied with the device file (refer to 17.3 ). 17.2.2 duty setting blocks the duty setting blocks output a signal whose duty factor can be changed in 256 steps. the duty factor of each output pin is independently set by the pwm data register (pwmr0 or pwmr1: peripheral address 05h or 06h) via the data buffer. 17.2.3 clock generation block the clock generation block generates a basic clock that is used to set the duty factor of the output signal. the generated clock frequency f pwm is 225 khz (refer to 17.4 ). control register output select block p1b 2 /pwm 1 duty setting block data buffer f pwm1 clock generation block output select block p1b 1 /pwm 0 f pwm0 duty setting block
m pd17016, 17017 213 17.3 output select blocks 17.3.1 configuration of output select blocks figure 17-2 shows the configuration of the output select blocks. figure 17-2. configuration of output select blocks 17.3.2 function of output select blocks the output select blocks select whether the p1b 2 /pwm 1 and p1b 1 /pwm 0 are used as general-purpose output port pins or d/a converter pins. this selection can be made by the pwm pin setting software macro supplied with the device file. each pin can be set in the port mode or d/a converter mode independently. the p1b 2 /pwm 1 and p1b 1 /pwm 0 pins are n-ch open-drain output pins and must be connected with an external pull-up resistor. table 17-1 lists the pwm pin setting software macros. table 17-1. pwm pin setting software macros function macro format uses p1b 1 /pwm 0 pin as pwm pin set1_pwm0on uses p1b 2 /pwm 1 pin as pwm pin set1_pwm1on uses p1b 1 /pwm 0 and p1b 2 /pwm 1 pins as pwm pins set2_pwm1on_pwm0on uses p1b 1 /pwm 0 pin as general-purpose output port pin clr1_pwm0on uses p1b 2 /pwm 1 pin as general-purpose output port pin clr1_pwm1on uses p1b 1 /pwm 0 and p1b 2 /pwm 1 pins general-purpose output port pins clr2_pwm1on_pwm0on uses p1b 1 /pwm 0 pin as pwm pin and p1b 2 /pwm 1 pin as general-purpose output port pin init_not_pwm1on_pwm0on uses p1b 1 /pwm 0 pin as general-purpose output port pin and p1b 2 /pwm 1 pin as pwm pin init_pwm1on_not_pwm0on caution if the above macros are used, the contents of the register window are destroyed. if the above macro instructions immediately follow an embedded macro instruction, an object error occurs when the source file is assembled and loaded to the in-circuit emulator. if an embedded macro exists immediately before the above macro instructions, insert a comment statement in between. output latch p1b 2 /pwm 1 1 0 duty setting block pwm pin setting software macro p1b 1 /pwm 0 1 0 duty setting block output latch
m pd17016, 17017 214 17.4 duty setting blocks and clock generation block 17.4.1 configuration of duty setting blocks and clock generation block figure 17-3 shows he configuration of the duty setting blocks and clock generation block. figure 17-3. configuration of duty setting blocks and clock generation block data buffer (dbf) address symbol data 0ch dbf3 don't care 0dh dbf2 don't care 0eh dbf1 0fh dbf0 m s b 8 peripheral address 06h pwm1 data register (pwmr1) comparator counter (8 bits) pwm0 data register (pwmr0) comparator counter (8 bits) 8 peripheral address 05h to output block to output block f pwm1 225 khz f pwm0 225 khz clock generation block l s b
m pd17016, 17017 215 17.4.2 function and configuration of clock generation blocks the clock generation blocks outputs basic clocks (f pwm1 and f pwm0 ) that set the duty factor of each output signal (of pwm 1 and pwm 0 pins). the output frequency is 225 khz (4.44 m s) for both f pwm1 and f pwm0 . however, f pwm1 and f pwm0 have the following phase difference. 17.4.3 function and operation of duty setting blocks the duty setting blocks compare the value set to each pwm data register (pwm1 and pwm0) with the value of each basic clock (f pwm1 and f pwm0 ) counted by an 8-bit counter, and output a high level if the value of the pwm data register is greater, and a low level if the value of pwm data register is less. where the value set to the pwm data register is x, the duty factor is as follows. x + 0.25 duty factor: d = 100 % 256 0.25 is an offset. a high level is output even when x = 0. because the basic clock is 225 khz, the frequency and cycle of the output signal are as follows. 225 khz frequency : f = = 878.9 hz 256 256 cycle : t = = 1137.8 m s 225 khz an independent value can be set to each pwm data register via the data buffer. in other words, each pin can output a signal with an independent duty factor. the following subsections 17.4.4 and 17.4.5 explain the configuration and function of each pwm data register, and the relation between the output waveform and duty factor of each pin. f pwm1 f pwm0 1.11 s 1.11 s 4.44 s mm m
m pd17016, 17017 216 17.4.4 configuration and function of each pwm data register the function of each pwm data register is illustrated below. the pwm data register sets the duty factor of a d/a converter (pwm output) output signal. name symbol address bit data data buffer dbf3 0ch don't care dbf2 0dh don't care dbf1 0eh dbf0 0fh b 3 b 2 b 1 b 0 b 3 b 2 b 1 b 0 b 3 b 2 b 1 b 0 b 3 b 2 b 1 b 0 transfer data 8 get can be executed put can be executed b 7 b 6 b 5 b 4 b 3 b 2 b 1 b 0 name peripheral register symbol pwmr0 pwmr1 valid data peripheral address 05h 06h peripheral hardware sets pwm output duty of each pin 0 x 255 x + 0.25 256 pwm 0 pin pwm 1 pin duty : d = 100 % = 878.9 hz 225 256 pwm0 data register pwm1 data register frequency : f = khz
m pd17016, 17017 217 17.4.5 relation of output waveform and each pin of d/a converter (1) shows the relation between the output waveform and duty factor. (2) shows the relation of the output waveform of each pin. (1) duty factor and output waveform (2) output waveform of each pin 17.5 status on reset 17.5.1 on power-on reset the p1b 2 /pwm 1 and p1b 1 /pwm 0 pins are set in the general-purpose output port mode. the output value is undefined. the value of each pwm data register is undefined. 17.5.2 on execution of clock stop instruction the p1b 2 /pwm 1 and p1b 1 /pwm 0 pins are set in the general-purpose output port mode. the output value is the previous contents of the output latch. each pwm data register retains the previous value. 17.5.3 on ce reset the p1b 2 /pwm 1 and p1b 1 /pwm 0 pins retain the previous output status. therefore, the pin used for the d/a converter retains the current pwm output. 17.5.4 in halt status the p1b 2 /pwm 1 and p1b 1 /pwm 0 pins retain the previous output status. therefore, the pin used for the d/a converter retains the current pwm output. x = 0 x = 1 x = 2 x = 255 4.44 s 4.44 s 1.11 s 3.33 s 1137.8 s mm m m m pwm 1 (x = 0) pwm 0 (x = 0) 1.11 s 1137.8 s m m
m pd17016, 17017 218 18. beep output the beep output function outputs a clock of 200 hz, 1 khz, or 3 khz from the p1b 0 /beep pin. 18.1 method of beep output the beep output function is controlled by a software macro defined in the device file. to start or stop the beep output, describe this software macro in the source program. (1) software macro starting beep output this macro sets the frequency of the beep output and the p1b 0 /beep pin in the beep output mode, to start the beep output. (a) to output 200 hz beepon200 (b) to output 1 khz beepon1k (c) to output 3 khz beepon3k (2) software macro stopping beep output this macro stops the beep output. consequently, the p1b 0 /beep pin can be used as a general-purpose output port pin, and the contents of the output latch at that time can be output. (a) to stop beep output beepoff caution if the above macros are used, the contents of the register window are destroyed. if the above macro instructions immediately follow an embedded macro instruction, an object error occurs when the source file is assembled and loaded to the in-circuit emulator. if an embedded macro exists immediately before the above macro instructions, insert a comment statement in between.
m pd17016, 17017 219 18.2 output waveform of beep the duty factor of the output waveform of beep is 50 %. the output waveform is shown below. (1) 200-hz output (2) 1-khz output (3) 3-khz output 18.3 status on reset (1) on power-on reset the p1b 0 /beep pin is set in the general-purpose output port mode. the value of the output latch is undefined, and therefore undefined data is output. (2) on execution of clock stop instruction the p1b 0 /beep pin is set in the general-purpose output port mode. the value of the output latch before the clock stop instruction is executed is retained, and the value of the output latch at that time is output. (3) on ce reset the p1b 0 /beep pin operates as is with the previous status retained. (4) in halt status the p1b 0 /beep pin operates as is with the previous status retained. 2.5 ms 2.5 ms 500 s 500 s mm 116.7 s 116.7 s mm
m pd17016, 17017 220 18.4 notes on using beep function the beep function block shares part of the hardware with the frequency counter that is explained later. therefore, the beep function and frequency counter cannot be used at the same time. if the data of the if counter mode select register and if counter data register (ifc: peripheral address 43h) are manipulated while the beep function is being used, the operation explained in 18.4.1 is performed. if the beep output software macro is executed while the frequency counter is being used, the operation explained in 18.4.2 is performed. 18.4.1 when beep function is used (1) when ifcmd1 and ifcmd0 flags of if counter mode select register are manipulated if a value other than 0 is written to the ifcmd1 and ifcmd0 flags, the p1b 0 /beep pin retains the current output level, and stops the beep output. when both the ifcmd1 and ifcmd0 flags are reset to 0, the beep output is started. (2) when if counter data register is manipulated the beep output is not affected even if the if counter data register is read (by get) or written (by put). an undefined value is read from the register. nothing is changed even if data is written to the register. however, do not write anything to the if counter data register because this register is a read-only register. 18.4.2 when frequency counter is being used if the beep output software macro is executed while the frequency counter is being used, the frequency counter is forcibly stopped, and the beep output is started. at this time, the contents of the window register (wr) and data buffer (dbf) are destroyed. to operate the frequency counter again, stop the beep output once by using the beepoff software macro, and start counting from the beginning.
m pd17016, 17017 221 19. serial interface the serial interface is used to transfer 8-bit serial data with an external device. figure 19-1. block diagram of serial interface control register data buffer clock control i/o con- trol clock generation presettable shift register serial interface p0b 2 /sck p0b 1 /so p0b 0 /si peripheral address 03h
m pd17016, 17017 222 19.1 configuration of serial interface figure 19-2 shows the configuration of the serial interface. as shown in the figure, the shift clock control block of the serial interface consists of a clock i/o pin block, clock generation block, wait control block, and clock count block. the serial data control block consists of a serial data i/o pin block and a presettable shift register. these blocks are controlled by the corresponding flags of the control registers. data is written to or read from the presettable shift register via the data buffer. the following section 19.2 outlines each block. figure 19-2. configuration of serial interface address flag symbol control register 02h data buffer (dbf) address symbol data 0ch dbf3 0dh dbf2 0eh dbf1 0fh dbf0 03h p0b 2 /sck output control output latch write port register read p0bbio2 flag p0b 2 /sck shift clock i/o pin block p0b 1 /so output control output latch write port register read p0bbio1 flag p0b 1 /so serial data i/o pin block output latch write port register read p0bbio0 flag p0b 0 /si sf8 sf8 wait serial clock input clkout clock control wait control clock counter shift clock output serial out data dataout clkin datain presettable shift register serial in data m s b l s b s i o 1 t s s i o 1 h i z s i o 1 c k 1 s i o 1 c k 0
m pd17016, 17017 223 19.2 functional outline of serial interface the serial interface uses the p0b 2 /sck, p0b 1 /so, and p0b 0 /si pins. the serial interface can select the internal clock or an external clock, and can execute reception and transfer operations. the following subsections 19.2.1 through 19.2.6 outline the functions of the respective blocks of the serial interface. for details of each block, refer to 19.3 through 19.7 . 19.2.1 shift clock i/o pin block this block selects a shift clock i/o pin. the shift clock i/o pin is selected by the serial i/o mode select register. refer to 19.3 . 19.2.2 serial data i/o pin block this block selects a serial data i/o pin. the serial data i/o pin is selected by the serial i/o mode select register. refer to 19.3 . 19.2.3 clock generation block this block selects the clock frequency of the shift clock and controls the shift clock output timing. the shift clock frequency is selected by the serial i/o mode select register. refer to 19.4 . 19.2.4 clock counter the clock counter counts the number of rising edges of the clock output by the shift clock output pin and outputs a signal at the eighth clock (sf8 signal). the sf8 signal is used to make serial communication wait (pause). refer to 19.5 . 19.2.5 presettable shift register (sio1sfr) this shift register sets serial out data and stores serial in data. it performs a shift operation by using the clock of the shift clock i/o pin and inputs/outputs data. the output data is set and the input data is read via the data buffer. refer to 19.6 . 19.2.6 wait control block this block controls places or releases serial communication in or from the wait status. serial communication is placed in or released from the wait status by the serial i/o mode select register. refer to 19.7 .
m pd17016, 17017 224 19.3 shift clock and serial data i/o pin control blocks the shift clock and serial data i/o pin control blocks sets the pins of the serial interface and controls the transfer/reception operation. these control operations are specified by the serial i/o mode select register. 19.3.1 shows the configuration and function of the serial i/o mode select register. 19.3.2 indicates the status of each pin set by the serial i/o mode select register. 19.3.1 configuration and function of serial i/o mode select register the configuration and function of the serial i/o mode select register are illustrated below. the sio1ck1 and sio1ck0 flags are used to select the internal clock or an external clock and to set the frequency of the internal clock. for the details on the clock, refer to 19.4 . the sio1ts flag places or releases the serial interface in or from the wait status. for the wait operation, refer to 19.7 . name flag symbol b 3 b 2 b 1 b 0 address 02h read/ write r/w 0 1 0 1 set i/o clock frequency of serial interface external clock (slave) 75 khz (master) 150 khz (master) 450 khz (master) on reset power-on clock stop ce 0 0 0 0 0 0 0 0 0 0 0 0 serial i/o mode select register sets p0b 1 /so pin as serial out pin general-purpose i/o port serial out starts serial communication of serial interface does not start serial communication (wait) starts serial communication (wait release) 0 1 0 1 0 0 1 1 s i o 1 t s s i o 1 h i z s i o 1 c k 1 s i o 1 c k 0
m pd17016, 17017 225 19.3.2 pin status setting by serial i/o mode select register table 19-1 shows the status of each pin set by the serial i/o mode select register. as shown in this table, the i/o select flag of each pin must be also manipulated to set each pin. for the details on the i/o select flag, refer to 15. general-purpose port . table 19-1. pin status setting by serial i/o mode select register communication mode sio1mode b 2 b 1 b 0 pin 3-wire serial i/o s i o 1 c k 0 s i o 1 c k 1 setting of serial output clock direction pin symbol s i o 1 h i z p 0 b b i o 1 p 0 b b i o 2 p 0 b b i o 0 wait : general-purpose input port wait released : external clock input external clock general- purpose port serial output internal clock 00 01 10 11 0 1 p0b 1 /so p0b 0 /si p0b 2 /sck 0 1 0 1 0 1 0 1 0 1 wait : general-purpose output port wait released : general-purpose output port wait : general-purpose input port wait released : general-purpose input port wait : high level output wait released : general-purpose input port general-purpose input port general-purpose output port general-purpose input port serial output serial input general-purpose output port i/o select flag of each pin set pin status
m pd17016, 17017 226 19.4 clock generation block the clock generation block generates the clock when the internal clock is used (i.e., when the master operation is performed) and controls the clock output timing. the frequency f sc of the internal clock is set by using the sio1ck1 and sio1ck0 flags of the serial i/o mode select register. the shift clock is successively output until the value of the clock counter, which is explained in 19.5, reaches 8. the following subsection 19.4.1 explains the clock output waveform and clock generation timing. 19.4.1 internal shift clock generation timing (1) on releasing wait status from initial status the initial status is the status in which the internal clock is selected, the p0b 2 /sck pin is set in the output mode, and a high level is output to this pin. a high level is output to the p0b 2 /sck pin in the wait status. 450 khz h l 150 khz h l 75 khz h l wait status initialization wait status 1/2 f sc 1/2 f sc 1/f sc
m pd17016, 17017 227 (2) when wait operation is performed for the details on the wait operation, refer to 19.7 . (a) wait status with value of clock counter reaching 8 (normal operation) (b) if forced wait is executed in wait status (c) if forced wait is executed when wait status is released at this time, the clock counter is reset. (d) if wait status is released in wait release status the clock output waveform is not changed at this time. the clock counter is not reset. (e) if clock frequency is changed and wait status is released at the same time the clock frequency can be changed and the wait status can be released by the serial i/o mode select register of the control registers. therefore, the clock frequency can be changed and the wait status can be released with a single instruction. in this case, the operation is the same as releasing the wait status from the initial status as explained in (1). shift clock pin h l wait period wait wait release 1/f sc wait released status shift clock pin h l wait period wait period forced wait b y sio1ts shift clock pin h l h l wait release status wait period 1/f sc forced wait by sio1ts wait release 1/f sc shift clock pin wait release status wait period forced wait by sio1ts wait release
m pd17016, 17017 228 19.5 clock counter the clock counter is a wrap-around counter that counts the number of the shift clocks output from or input to the shift clock (p0b 2 /sck) pin. the clock counter directly reads the status of the shift clock pin. at this time, whether the clock is the internal clock or an external clock is not identified. the clock counter does not operate in the wait status of serial communication. when the value of the clock counter is 8, serial communication is placed in the wait status at the rising edge of the shift clock. the contents of the clock counter cannot be directly read by programs. the following subsections 19.5.1 and 19.5.2 explain the operation of the clock counter and the conditions under which the clock counter is reset. 19.5.1 operation of clock counter figure 19-3 shows the operation of the clock counter. the initial value of the clock counter is 0. the value of the clock counter is incremented by one each time the falling of the shift clock pin is detected. when the value of the clock counter has been incremented to 8, the clock counter is reset to 0 at the next rising edge of the shift clock pin. serial communication is placed in the wait status when the clock counter has been reset to 0. figure 19-3. operation of clock counter 19.5.2 clock counter reset condition the clock counter is reset to 0 when any of the following conditions (1) through (5) is satisfied. (1) on power-on reset (2) on execution of the clock stop instruction (3) when 0 is written to the sio1ts flag (forced wait) (4) when the shift clock rises while the value of the clock counter is 8 with the wait status released (5) on ce reset shift clock pin h l serial data pin h l clock counter resets clock counter releases wait 012 3 780 123 78 d7 d6 d1 d5 d0 wait
m pd17016, 17017 229 19.6 presettable shift register (sio1sfr) the presettable shift register is an 8-bit shift register that writes serial out data and reads serial in data. data is written to or read from the presettable shift register via the data buffer by using the put or get instruction. 19.6.1 shows the configuration of the presettable shift register and its relation with the data buffer. the presettable shift register performs its shift operation in synchronization with the clock applied to the shift clock (p0b 2 /sck) pin. at this time, the content of the most significant bit (msb) of the presettable shift register is output to the serial data output pin in synchronization with the fall of the shift clock, and the least significant bit (lsb) of the presettable shift register is read in synchronization with the rise of the clock. 19.6.2 explains the operation of the presettable shift register. 19.6.3 explains the points to be noted in writing or reading data to or from the presettable shift register. the presettable shift register does not shift data in the wait status. for the details on the operation in each serial communication mode, refer to 19.8 . 19.6.1 configuration of presettable shift register and its relation with data buffer the configuration of the presettable shift register and its relation with the data buffer are shown below. name symbol address bit data data buffer dbf3 0ch don't care dbf2 0dh don't care dbf1 0eh dbf0 0fh b 3 b 2 b 1 b 0 b 3 b 2 b 1 b 0 b 3 b 2 b 1 b 0 b 3 b 2 b 1 b 0 transfer data 8 get can be executed put can be executed b 7 b 6 b 5 b 4 b 3 b 2 b 1 b 0 name peripheral register symbol sio1sfr valid data peripheral address 03h peripheral hardware sets serial out data and reads serial in data d7 d6 d5 d4 d3 d2 d1 d0 serial out presettable shift register d7 d6 d5 d4 d3 d2 d1 d0 l s b m s b serial interface serial in
m pd17016, 17017 230 19.6.2 operation of presettable shift register figure 19-4 illustrates the data shift operation of the presettable shift register. table 19-2 shows the data shift operation during transfer and reception. figure 19-4. data shift operation of presettable shift register table 19-2. data shift operation during transfer and reception serial i/o mode serial input operation serial output operation shifts and inputs status of p0b 0 /si pin at rising edge of shift clock starting from lsb. if p0bbio0 flag is 0, contents of output latch are input. this operation is not performed in wait status. shift clock pin h l serial data input pin h l serial data output pin h l wait release clock counter presettable shift register b 7 b 6 b 5 b 4 b 3 b 2 b 1 b 0 d7 d6 d5 d4 d3 d2 d1 d0 d6 d5 d4 d3 d2 d1 d0 d7 d5 d4 d3 d2 d1 d0 d7 d6 d1 d0 d7 d6 d5 d4 d3 d2 d0 d7 d6 d5 d4 d3 d2 d1 d7 d6 d5 d4 d3 d2 d1 d0 d7 d5 d2 d6 d1 d0 d0 d1 d2 d6 d7 0 780 6 12 12 678 3 d5 data is shifted and output, starting from msb, to p0b 1 /so pin at falling edge of shift clock. if p0bbio1 flag is 1, or if sio1hiz flag is 0, data is not output. this operation is not performed in wait status.
m pd17016, 17017 231 19.6.3 notes on setting and reading data data is written to the presettable shift register by the put sio1sfr, dbf instruction. data is read from the register by the get dbf, sio1sfr instruction. set or read data to or from the register in the wait status. while the wait status is released, the data may not be correctly set or read depending on the status of the shift clock pin. table 19-3 indicates the timing of setting and reading data and points to be noted. table 19-3. reading (get) and writing (put) data from/to presettable shift register and notes status on execution status of shift clock pin presettable shift register (sio1sfr) of put/get wait read (get) with external clock: normally read. status floated write (put) normally written. with internal clock: content of msb is output at falling edge of shift clock when wait high level status is released next time (during transfer operation). wait read (get) low level normally read. released high level cannot be read normally. status contents of sio1sfr are destroyed. write (put) high level normally written. contents of msb are output when put instruction is executed. clock counter is not reset. low level cannot be written normally. contents of sio1sfr are destroyed. clock data put sio1sfr , dbf wait released msb clock data msb put sio1sfr , dbf
m pd17016, 17017 232 19.7 wait block the wait block controls communication of the serial interface by placing or releasing communication in or from the wait status. the wait block is controlled by the sio1ts flag of the serial i/o mode select register. the following subsection 19.7.1 explains the wait operation and points to be noted. 19.7.1 wait operation and notes in the wait status, the clock generation block and presettable shift register stop operation, and serial communication pauses. therefore, serial communication can be started when the wait status is released. the wait status is released when 1 is written to the sio1ts flag. when 1 is written to this flag, the internal clock is output to the shift clock output pin (during master operation), and presettable shift register and clock counter start operating. if the shift clock rises when the value of the clock counter is 8, the wait status is set. at this time, the sio1ts flag is automatically reset to 0. the operating status of serial communication can be checked by detecting the content of the sio1ts flag while the wait status is released. therefore, data is read or set after 1 has been written to the sio1ts flag, serial communication has been started, and then clearing of the sio1ts flag to 0 has been detected. if data is written to (by put instruction) or read from (by get instruction) the presettable shift register while the wait status is released, the correct data may not be written or read. for details, refer to 19.6.3 notes on setting and reading data . if 0 is written to the sio1ts flag while the wait status is released, the wait status is set. this is called forced wait. when forced wait is executed, the clock counter is reset to 0. figure 19-5 shows an example of the wait operation.
m pd17016, 17017 233 figure 19-5. example of wait operation when the wait status is released, the serial data is output at the next falling edge of the clock, and the wait status is released. when the shift clock has been input eight times, the shift clock pin outputs a high level, and the clock counter and presettable shift register stop operation. if data is written to or read from the presettable shift register while the wait status is released and the shift clock pin is high, the correct data may not be set or read. if data is written to the presettable shift register while the wait status is released and the shift clock pin is low, the content of the msb is output to the serial data output pin as soon as the put instruction has been executed. if forced wait is executed while the wait status is released, the wait status is set and the clock counter is reset to 0 as soon as 0 has been written to the sio1ts flag. h l serial data input pin h l shift clock pin sio1ts 1 0 h l serial data output pin clock counter wait status wait released wait released status wait status wait 0780 3 12 previous value d7 d7 d6 d6 d1 d1 d0 d0 d5 d5 123 78
m pd17016, 17017 234 19.8 using serial interface figure 19-6 illustrates the i/o block and communication method of the serial interface. table 19-4 indicates the operations of the serial interface in each mode. as shown in figure 19-6 and table 19-4, the serial interface operates on the internal clock (master operation) or external clock (slave operation), and can perform transfer and reception on both the clocks. the master or slave operation is selected by the sio1ck1 and sio1ck0 flags. reception or transfer is selected by the sio1hiz flag. during the master operation, the internal shift clock is output from the p0b 2 /sck pin. however, the p0b 2 / sck pin must be set in the output port mode (p0bbio2 flag = 1). during the slave operation, the p0b 2 /sck pin is floated, and the serial interface waits for an external clock. at this time, the p0b 2 /sck pin must be set in the input port mode (p0bbio2 flag = 0). serial data is output from the p0b 1 /so pin at the falling edge of the shift clock, regardless of whether the internal clock or external clock is used. however, the p0b 1 /so pin must be set in the output port mode (p0bbio1 flag = 1) and the sio1hiz flag must be set. as the serial input data, the status of the p0b 1 /so pin is input to the presettable shift register at the rising edge of the shift clock, regardless of whether the internal clock or external clock is used. however, the p0b 0 / si pin must be set in the input port mode (p0bbio0 flag = 0). the p0b 2 /sck pin reads the current status of the output latch when the value output to the pin is read, and the current status of the pin while the wait status is released. paragraphs (1) through (4) below table 19-4 show program examples of transfer and reception during master and slave operations.
m pd17016, 17017 235 figure 19-6. i/o block and communication method of serial interface (1/2) 1 0 1 0 v dd v dd p0bbio2 p0b 2 /sck i/o control block sio1ts sio1ck1 sio1ck0 p-ch n-ch shift clock output shift clock input p0b 2 /sck p0b2 output latch write port register read 1 0 1 0 v dd v dd p-ch n-ch serial data output p0b 1 /so p0b1 output latch write port register read p0bbio1 sio1hiz p0b 1 /so i/o control block 1 0 v dd v dd p-ch n-ch serial data input p0b 0 /si p0b0 output latch write port register read p0bbio0 p0b 0 /si i/o control block wait signal i/o block
m pd17016, 17017 236 figure 19-6. i/o block and communication method of serial interface (2/2) d7 d6 d1 h l si pin d7 d6 d1 h l so pin 1 h l sck pin d0 d0 2378 data read data output wait released hardware control wait status communication
m pd17016, 17017 237 table 19-4. operation of serial interface in each mode operation 3-wire serial i/o mode mode slave operation master operation item sio1ck1 = sio1ck0 = 0 sio1ck1 = sio1ck0 = other than 0 wait wait released wait wait released setting p0b 2 /sck status of each pin p0b 1 /so p0b 0 /si when p0bbio0 = 0 floating waits for external data when p0bbio0 = 1 general-purpose output port. outputs contents of output latch. usually, p0bbio0 is cleared to 0. operation of clock incremented at falling edge of sck pin. counter operation of output presettable shift when sio1hiz = 1 register (sio1sfr) shifts data from msb and outputs it to so 2 pin at falling edge of sck pin. when sio1hiz = 0 does not output data. input shifts data of si pin from lsb and inputs it at rising edge of sck pin regardless of p0bbio0. however, the contents of output latch are output to si pin when p0bbio0 = 1. wait operation serial communication is started when 1 is written to sio1ts. sio1ts is reset to 0 at rising edge of shift clock when value of clock counter is 8. for operation of each pin, refer to above. when p0bbio2 = 0 floating general-purpose input port when p0bbio2 = 1 general-purpose output port outputs contents of output. usually, p0bbio2 is cleared to 0. when sio1hiz = 0 when p0bbio1 = 0 general-purpose input port floating when p0bbio1 = 1 general-purpose output port outputs contents of output latch. when p0bbio2 = 0 floating external clock input when p0bbio2 = 1 general-purpose output port outputs contents of output latch. when sio1hiz = 1 when p0bbio1 = 0 general-purpose input port floating when p0bbio1 = 1 outputs serial data. when p0bbio2 = 0 floating general-purpose input port when p0bbio2 = 1 outputs high level. usually, p0bbio2 is set to 1. when sio1hiz = 0 when p0bbio1 = 0 general-purpose input port floating when p0bbio1 = 1 general-purpose output port outputs contents of output latch. when p0bbio2 = 0 floating general-purpose input port when p0bbio2 = 1 outputs internal clock. when sio1hiz = 1 when p0bbio1 = 0 general-purpose input port floating when p0bbio1 = 1 outputs serial data.
m pd17016, 17017 238 (1) program example of serial interface (in master transfer mode) example to transfer 2-byte data a596h sckbio flg p0bbio2 sobio flg p0bbio1 mov dbf1, #0ah ; sets transfer data mov dbf0, #5 put sio1sfr, dbf set2 sckbio, s0bio initflg sio1ts, sio1hiz, not sio1ck1, sio1ck0 ; releases wait, and outputs serial data ; master (f sc = 75 khz) loop1: skf1 sio1ts ; wait until wait status is released br loop1 mov dbf1, #9 ; sets transfer data mov dbf0, #6 put sio1sfr, dbf set1 sio1ts ; releases wait loop2: skf1 sio1ts ; waits until wait status is released br loop2 . . . (2) program example of serial interface (in master reception mode) example to receive 2-byte data and store it to addresses 00h through 03h of bank0 sckbio flg p0bbio2 sibio flg p0bbio0 data1h mem 0.00h ; stores high-order 4 bits of first byte data1l mem 0.01h ; stores low-order 4 bits of first byte data2h mem 0.02h ; stores high-order 4 bits of second byte data2l mem 0.03h ; stores low-order 4 bits of second byte initflg sckbio, not sibio initflg sio1ts, not sio1hiz, sio1ck1, sio1ck0 ; releases wait, and does not output serial data ; master (f sc = 450 khz) loop1: skf1 sio1ts ; wait until wait status is released br loop1 get dbf, sio1sfr ; reads receive data st data1h, dbf1 ; stores read data st data1l, dbf0 set1 sio1ts ; releases wait loop2: skf1 sio1ts ; waits until wait status is released br loop2 get dbf, sio1sfr ; reads receive data st data2h, dbf1 ; stores read data st data2l, dbf0 . . .
m pd17016, 17017 239 (3) program example of serial interface (in slave transfer mode) example to transfer 2-byte data a596h sckbio flg p0bbio2 sobio flg p0bbio1 initflg not sckbio, sobio mov dbf1, #0ah ; sets transfer data mov dbf0, #5 put sio1sfr, dbf initflg sio1ts, sio1hiz, not sio1ck1, not sio1ck0 ; releases wait, outputs serial data, slave loop1: skf1 sio1ts ; wait until wait status is released br loop1 mov dbf1, #9 ; sets transfer data mov dbf0, #6 put sio1sfr, dbf set1 sio1ts ; releases wait loop2: skf1 sio1ts ; waits until wait status is released br loop2 . . . (4) program example of serial interface (in slave reception mode) example to receive 2-byte data and store it to addresses 00h through 03h of bank0 sckbio flg p0bbio2 sibio flg p0bbio0 data1h mem 0.00h ; stores high-order 4 bits of first byte data1l mem 0.01h ; stores low-order 4 bits of first byte data2h mem 0.02h ; stores high-order 4 bits of second byte data2l mem 0.03h ; stores low-order 4 bits of second byte clr2 sckbio, sibio initflg sio1ts, not sio1hiz, not sio1ck1, not sio1ck0 ; releases wait, does not output serial ; data, slave loop1: skf1 sio1ts ; wait until wait status is released br loop1 get dbf, sio1sfr ; reads receive data st data1h, dbf1 ; stores read data st data1l, dbf0 set1 sio1ts ; releases wait loop2: skf1 sio1ts ; waits until wait status is released br loop2 get dbf, sio1sfr ; reads receive data st data2h, dbf1 ; stores read data st data2l, dbf0 . . .
m pd17016, 17017 240 19.9 status of serial interface on reset 19.9.1 on power-on reset all of the pins p0b 2 /sck through p0b 0 /si are set in the general-purpose input port mode (floating output). the value of the presettable shift register is undefined. 19.9.2 on execution of clock stop instruction all of the pins p0b 2 /sck through p0b 0 /si are set in the general-purpose input port mode (floating output). the presettable shift register retains the previous value. 19.9.3 on ce reset all of the pins p0b 2 /sck through p0b 0 /si are set in the general-purpose input port mode (floating output). the presettable shift register retains the previous value. 19.9.4 in halt status the i/o pins retain the current status. if the internal clock is used (master operation) at this time, the clock is not output after the halt instruction has been executed. to use the internal clock, therefore, the halt instruction must be executed after communication has been completed. if an external clock is forcibly input, the serial interface functions even when the internal clock is used. if the external clock is used (slave operation), the operation continues even when the halt instruction has been executed.
m pd17016, 17017 241 20. frequency counter (fc) the frequency counter (fc) is used to count the intermediate frequency (if) of a tuner. 20.1 configuration of frequency counter figure 20-1 shows the block diagram of the frequency counter. as shown in the figure, the if counter consists of an input select block, gate time control block, start/stop control block, and count block. figure 20-1. block diagram of frequency counter 20.2 functional outline of frequency counter the frequency counter has an if counter function that is used to count the frequency of an externally input signal. the if counter function is to count the frequency input to the p1d 3 /fmifc or p1d 2 /amifc pin by using a 16- bit counter at fixed time intervals (1 ms, 4 ms, 8 ms, or open). the following subsections 20.2.1 through 20.2.4 outline each function block of the frequency counter. because the frequency counter shares the hardware with the beep function explained in 18. beep output , it cannot be used with the beep function at the same time. for details, refer to 20.7 notes on using frequency counter . 20.2.1 if counter input select block the if counter input select block specifies whether the p1d 3 /fmifc and p1d 2 /amifc pins are used as general-purpose input port pins or if counter pins. this selection is made by the if counter mode select register (rf address 12h). for details, refer to 20.3 . control register if counter input select data buffer if counter (16 bits) gate time control start/stop control p1d 3 /fmifc p1d 2 /amifc
m pd17016, 17017 242 20.2.2 gate time control block the gate time control block controls the time during which the frequency is counted by the if counter mode select register. the if counter mode select register sets the internal gate time (1 ms, 4 ms, 8 ms, or open) to count the frequency applied to the p1d 3 /fmifc or p1d 2 /amifc pin. for details, refer to 20.3 . 20.2.3 start/stop control block the start/stop control block starts or stops the frequency counter. starting or stopping the frequency counter is controlled by the if counter control register (rf address 23h) and if counter gate judge register (rf address 04h). for details, refer to 20.4 . 20.2.4 if counter the input frequency is counted by a 16-bit binary counter. the count value is read by the if counter data register (ifc: peripheral address 43h) via the data buffer. for details, refer to 20.4 .
m pd17016, 17017 243 20.3 input select block and gate time control block 20.3.1 configuration of input select block and gate time control block figure 20-2 shows the configuration of the input select block and gate time control block. figure 20-2. configuration of input select block and gate time control block input port v dd p1d 2 /amifc input port v dd p1d 3 /fmifc 1/2 address bit flag symbol control register 12h b 3 b 2 b 1 b 0 gate time generator (1, 4, 8 ms) beep 2-3 decoder frequency gate time signal a m i f c f m i f c i f c m d i i f c c k 1 i f c m d 0 i f c c k 0
m pd17016, 17017 244 20.3.2 function of input select block the input select block selects whether the p1d 3 /fmific and p1d 2 /amifc pins are used as general-purpose output port pins or frequency counter pins. this selection is made by the ifcmd1 and ifcmd0 flags of the if counter mode select register (refer to 20.3.4 ). 20.3.3 function of gate time control block the gate time control block sets a gate time (count time). the gate time is set by the ifcck1 and ifcck0 flags of the if counter mode select register (refer to 20.3.4 ).
m pd17016, 17017 245 20.3.4 configuration and function of if count mode select register the if counter mode select register selects the if counter function and gate time. the configuration and function of this register are illustrated below. because the frequency counter is shared with the beep function, this register is also used to select the beep output. caution the if counter function and beep function cannot be used at the same time. name flag symbol b 3 b 2 b 1 b 0 address 12h read/ write r/w 0 1 0 1 gate time of if counter 1 ms 4 ms 8 ms open on reset power-on clock stop ce 0 0 0 0 0 0 0 0 if counter mode select register 0 0 1 1 0 1 0 1 selects if counter or beep function beep output if counter (fmifc) if counter (amifc) setting prohibited 0 0 1 1 retained i f c c k 0 i f c c k 1 i f c m d 0 i f c m d 1
m pd17016, 17017 246 20.4 start/stop control block and if counter 20.4.1 configuration of start/stop control block and counter figure 20-3 shows the configuration of the start/stop control block and counter. figure 20-3. configuration of start/stop control block and counter 20.4.2 function of start/stop control block the start/stop control block detects the start and end of counting by the frequency counter. the counting is started by using the ifcstrt flag of the if counter control register. to detect the end of the counting, the ifcgostt flag of the if counter gate judge register is used. the following subsections 20.4.6 and 20.4.7 explain the configuration and functions of the if counter control register and if counter gate judge register. control register address bit flag symbol 04h b 3 0 b 2 0 b 1 0 b 0 control register address bit flag symbol 23h b 3 0 b 2 0 b 1 b 0 data buffer (dbf) address symbol data 0ch dbf3 0dh dbf2 0eh dbf1 0fh dbf0 if counter data register (ifc) 16 16 if counter (16 bits) res peripheral address 43h high-order 6 bits are shared with beep function block. gate signal from input select block start/stop i f c g o s t t m s b l s b i f c s t r t i f c r e s
m pd17016, 17017 247 20.4.3 gate operation of if counter (1) when 1, 4, or 8 ms is selected as gate time the gate is opened for 1, 4, or 8 ms since the internal 1-khz signal has risen after the ifcstrt flag was set to 1, as shown below. while this gate is open, the frequency input from the pin is counted by the 16-bit counter. when the gate is closed, the ifcgostt flag is reset. the ifcgostt flag is automatically set to 1 when the ifcstrt flag has been set. h l internal 1 khz open close 1 ms 4 ms 8 ms gate time count period (ifcgostt flag = 1) gate is actually opened at this point. sets ifcstrt flag. ifcgostt flag is set at this point. end of counting. ifcgostt flag is reset.
m pd17016, 17017 248 (2) when open is selected as gate time as soon as it has been specified by the ifcck1 and ifcck0 flags that the gate is opened, the gate is opened. if counting is started by the ifcstrt flag while the gate is open, the gate is closed after an undefined time. therefore, do not set the ifcstrt flag to 1 when selecting open as the gate time. however, the counter can be reset by the ifcres flag. when open is selected as the gate time, the gate can be opened or closed in two ways as explained in (a) and (b) below. (a) set gate time other than open by ifcck1 and ifcck0 flags (b) unselect pin used by using ifcmd1 and ifcmd0 flags in this case, the gate is remains open, and counting is stopped by inhibiting input from the pin. h l internal 1 khz open close gate count period if ifcstrt flag is set during this period, gate is closed after undefined time. ifcck1 = ifcck0 = 1 gate is actually opened at this point. if g ate is opened while ifcgostt fla g is 1, it is closed after undefined time. open close gate count time ifcck1 = ifcck0 = 1 ifcmd1 = ifcmd0 = 0 (beep) fmifc and amifc pins are unselected, and count input is inhibited. open close gate count time ifcck1 = ifcck0 = 1 set other than open by iffcck1 and ifcck0 flags.
m pd17016, 17017 249 20.4.4 function and operation of 16-bit counter the 16-bit counter counts up the frequency input within the specified gate time. this counter is reset by writing 1 to the ifcres flag of the if counter control register. when the 16-bit counter counts up to ffffh, it is cleared to 0000h and continues counting when the next input is applied. because the high-order 6 bits of this counter are shared with the beep function, the frequency counter and beep function cannot be used at the same time. the function of the if counter is to count the frequency input to the p1d 3 /fmifc or p1d 2 /amifc pin while the gate is open. note, however, that the frequency input to the p1d 3 /fmifc pin is divided by two and is counted. the relation between count value x (hex) and input frequency (f fmifc or f amifc ) is as follows. fmifc x (dec) f fmifc = 2 (khz) t gate = gate time (1, 4, or 8 ms) t gate amifc x (dec) f amifc = (khz) t gate = gate time (1, 4, or 8 ms) t gate the value of the if counter data register is read via the data buffer. the following subsection 20.4.5 explains the configuration and function of the if counter data register.
m pd17016, 17017 250 20.4.5 configuration and function of if counter data register (ifc) the configuration and function of the if counter data register are illustrated below. the if counter data register reads the count value of the frequency counter. this register is cleared to 0000h at the next input when its value has reached ffffh, and continues counting. the high-order 6 bits of the if counter are shared with the beep function. therefore, the frequency counter function and beep function cannot be used at the same time. for details, refer to 20.7 notes on using frequency counter . name symbol address bit data data buffer dbf3 0ch dbf2 0dh dbf1 0eh dbf0 0fh b 3 b 2 b 1 b 0 b 3 b 2 b 1 b 0 b 3 b 2 b 1 b 0 b 3 b 2 b 1 b 0 transfer data 16 get can be executed nothing is changed even if put is executed. b 15 b 14 b 13 b 12 b 11 b 10 b 9 b 8 b 7 b 6 b 5 b 4 b 3 b 2 b 1 b 0 name peripheral register symbol ifc valid data peripheral address 43h peripheral hardware frequency counter count value of frequency counter if counter data register 0 x 2 16 C 1 (ffffh) if counter function fmif counter counts rising edge of signal input to p1d 3 /fmifc pin by using 1/2 divider amif counter counts rising edge of signal input to p1d 2 /amifc pin.
m pd17016, 17017 251 20.4.6 configuration and function of if counter control register the if counter control register starts the frequency counter (if counter) function and controls resetting of the 16-bit counter. the configuration and function of this register are illustrated below. the if counter control register is controlled by writing the contents of the window register by using the poke instruction. when the contents of this register are read to the window register by the peek instruction, 0 is read. if either of the ifcres or ifcstrt flag is set by using the assembler (as17k) embedded macroinstruction setn, the flag that is not set becomes undefined, and an error occurs. for details, refer to 20.7.3 notes on using embedded macroinstruction setn to ifcres and ifcstrt flags . name flag symbol b 3 0 b 2 0 b 1 b 0 address 23h read/ write w 0 1 controls count value of if counter nothing is changed. resets counter. on reset power-on clock stop ce 000 0 0 0 if counter control register fixed to "0" 0 1 starts counting by if counter nothing is changed. starts counting. retained i f c r e s i f c s t r t
m pd17016, 17017 252 20.4.7 configuration and function of if counter gate judge register the if counter gate judge register detects the opening and closing of the gate of the if counter. the configuration and function of this register are illustrated below. caution do not read the contents of the if counter data register (ifc) to the data buffer while the ifcgostt flag is set to 1 (i.e., while the gate is open). name flag symbol b 3 0 b 2 0 b 1 0 b 0 address 04h read/ write r detects opening/closing of gate of frequency counter set to 1 until gate time expires after ifcstrt flag has been set to "1". on reset power-on clock stop ce 0000 if counter gate judge register fixed to "0" i f c g o s t t unde- fined unde- fined
m pd17016, 17017 253 20.5 using if counter function the following subsections 20.5.1 through 20.5.3 explain how to use the hardware of the if counter function, program example, and count error. 20.5.1 using hardware of if counter figure 20-4 shows the block diagram illustrating how the p1d 3 /fmifc and p1d 2 /amifc pins are used. table 20-1 shows the range of the frequencies that can be input to the p1d 3 /fmifc and p1d 2 /amifc pins. because the input pins of the if counter have an internal amplifier, cut off the dc component of the input signal by using capacitor c as shown in figure 20-4. when the p1d 3 /fmifc or p1d 2 /amifc pin is selected as the if counter pin, switch sw turns on, applying a voltage of about 1/2v dd to each pin. if the voltage has not risen to a sufficient intermediate level at this time, the ac amplifier does not operate normally, and consequently, the if counter does not correctly operate. therefore, make sure that a sufficiently long wait time elapses from the time each pin is selected as an if counter until counting is started. figure 20-4. function of each if counter pin table 20-1. input frequency range of if counter input pin input frequency input amplitude (mhz) (v p-p ) p1d 3 /fmifc 5-15 0.3 10.5-10.9 0.06 p1d 2 /amifc 0.1-1 0.3 0.44-0.46 0.05 to internal counter sw r fmifc amifc c external frequency
m pd17016, 17017 254 20.5.2 program example of if counter function a program example of the if counter function is shown below. as shown in this example, wait time must elapse after an instruction that selects the p1d 3 /fmifc or p1d 2 / amifc pin as the if counter pin has been executed before counting is started. this is because the internal ac amplifier may not operate normally immediately after each pin has been selected, as explained in 20.5.1. example to count frequency on p1d 3 /fmifc pin (gate time: 8 ms) initflg not ifcmd1, ifcmd0, ifcck1, not ifcck0 ; selects fmifc pin and sets gate time to 8 ms. wait ; internal ac amplifier stabilization time ifc_res_and_start ; resets and starts counter (sets ifcres and ; ifcstrt flags) note . ; macro definition is used because set2 instruction cannot ; be used. loop: skt1 ifcgostt ; detects opening/closing of gate. br read ; branches to read: when gate is closed. processing a ; do not read data of if counter by this processing a. ; do not select beep function. br loop read: get dbf, ifc ; reads value of if counter data register to data buffer. note refer to 20.7.3 notes on using embedded macroinstruction setn to ifcres and ifcstrt flags . 20.5.3 error of if counter the if counter may have a gate time error and a count error. these errors are explained in (1) and (2) below. (1) error of gate time the gate time of the if counter is created by dividing the 4.5-mhz system clock. therefore, if the system clock deviates +x ppm, the gate time deviates Cx ppm. (2) count error the if counter counts the frequency at the rising edge of an input signal. if a high level is input to the pin when the gate is opened, therefore, one excess pulse is counted. however, counting is not performed because of the status of the pin when the gate is closed. therefore, a count error of +1, C0 may occur.
m pd17016, 17017 255 20.6 status on reset 20.6.1 on power-on reset the p1d 3 /fmifc and p1d 2 /amifc pins are set in the general-purpose input port mode. 20.6.2 on execution of clock stop instruction the p1d 3 /fmifc and p1d 2 /amifc pins are set in the general-purpose input port mode. 20.6.3 on ce reset the p1d 3 /fmifc and p1d 2 /amifc pins retain the previous status. 20.6.4 in halt status the p1d 3 /fmifc and p1d 2 /amifc pins retain the status immediately before the halt status is set. to release the halt status by using the interrupt of the frequency counter, the following point must be noted. caution if the halt instruction is executed after counting has been started by the ifcstrt flag and before the gate is actually opened, the gate will not be opened. therefore, wait at least 1 ms after starting counting before executing the halt instruction. figure 20-5 shows the gate operation when the halt instruction is executed. because the closing of the gate cannot be detected unless the gate is opened, the interrupt request is not issued. if interrupts other than that of the if counter are not enabled with halt release conditions other than the interrupt not specified, the halt status will not be released. figure 20-5. gate operation when halt instruction is used open close gate interrupt request is not issued because gate is not opened if halt instruction is executed during this period. sets ifcstrt flag. gate is actually opened at this point.
m pd17016, 17017 256 20.7 notes on using frequency counter the frequency counter shares its hardware with the beep function explained earlier. therefore, the beep function and frequency counter cannot be used at the same time. if the data of the if counter mode select register and if counter data register are manipulated while the beep function is used, the operation explained in 20.7.1 is performed. if the beep output software macro is executed when the frequency counter is used, the operation explained in 20.7.2 is performed. the assembler embedded macroinstruction setn cannot be used to manipulate the ifcres and ifcstrt flags, as explained in 20.4.6. this is explained in more detail in 20.7.3. 20.7.1 when beep output is used (1) when ifcmd1 and ifcmd0 flags of if counter mode select register are manipulated if a value other than 0 is written to the ifcmd1 and ifcmd0 flags, the p1b 0 /beep pin retain the current output level, and stops the beep output. when both the ifcmd1 and ifcmd0 flags are reset to 0 again, the beep output is started. (2) when if counter data register is manipulated the beep output is not affected even if a read (get) or write (put) instruction is executed. when the if counter data register is read, an undefined value is read. nothing is changed even if data is written to the register. note, however, that the if counter data register is a read-only peripheral register. do not write data to this register. if the write instruction put ifc, dbf is executed, the 17 series assembler outputs an error. 20.7.2 when frequency counter is used if the beep output software macro is executed while the frequency counter is used, the frequency counter is forcibly stopped, and the beep output is started. at this time, the contents of the window register (wr) and data buffer (dbf) are destroyed. to operate the frequency counter again, once stop the beep output by using the beepoff macro, and start counting from the beginning.
m pd17016, 17017 257 20.7.3 notes on using embedded macroinstruction setn to ifcres and ifcstrt flags because the ifcres and ifcstrt flags are in a write-only register, an undefined value is read if these flags are read. if either of these flags is set by assembler (as17k) embedded macroinstruction setn, an undefined value is written to the other flag. set1 ifcres peek wr,.mf.ifcres shr4 ; value of wr is undefined at this time. or wr,#.df.ifcres and 0fh ; only bit 0 of wr is set. poke .mf.ifcres shr 4, wr ; undefined value is written to ifcstrt (bit 1). if the setn instruction is executed to the ifcres and ifcstrt flag, therefore, the assembler outputs an error. therefore, use macro definition to manipulate the ifcres and ifcstrt flags as follows. ifcw mem 0.0a3h ; ifc_res_and_start macr0 mov wr, #0011b poke ifcw, wr endm ; ifc_res macr0 mov wr, #0001b poke ifcw, wr endm ; ifc_start macr0 mov wr, #0010b poke ifcw, wr endm the above macroinstruction is supplied with the device file as ifcset.lib file and d17016.inc/d17017.inc file. therefore, the above macroinstruction can be used as is by includeing these files on the source program. for how to use each file, refer to as17016 device file users manual . ????????????????????????????????????????????
m pd17016, 17017 258 21. lcd controller/driver the lcd (liquid crystal display) controller/driver can display an lcd of up to 60 dots by outputting segment and common signals in combination. 21.1 configuration of lcd controller/driver figure 21-1 shows the block diagram of the lcd controller/driver. as shown in the figure, the lcd controller/driver consists of a common signal output timing control block, segment signal/key source signal output timing control block, segment signal/output port select block, lcd segment register, and key source signal output control block. the following section 21.2 outlines the function of each block. figure 21-1. block diagram of lcd controller/driver control register lcd segment register data memory space key source signal output control data buffer segment signal/key source signal output timing control common signal output timing control segment signal/ output port select selection by software macro l c d 0 / k s 0 l c d 15 / k s 15 l c d 16 l c d 21 l c d 22 / p 0 e 0 l c d 25 / p 0 e 3 l c d 26 / p 0 f 0 l c d 29 / p 0 f 3 c o m 0 c o m 1
m pd17016, 17017 259 21.2 functional outline of lcd controller/driver the lcd controller/driver can display up to 60 dots by using the combination of common signal output pins (com 1 and com 0 ) and segment signal output pins (lcd 29 /p0f 3 through lcd 0 /ks 0 ). figure 21-2 shows the relation among common signal output pins, segment signal output pins, and display dots. as shown in this figure, two dots at the intersections between one segment line with com 1 and com 0 pins. the driving mode is 1/2 duty, 1/2 bias, and the drive voltage is supply voltage v dd . the segment signal output pins (lcd 29 /p0f 3 through lcd 22 /p0e 0 ) pins can also be used as general-purpose output port pins. when these pins are used as general-purpose output port pins, ports 0f (lcd 29 /p0f 3 through lcd 26 /p0f 0 ) and 0e (lcd 25 /p0e 3 through lcd 22 /p0e 0 ) can be independently used. of the segment signal output pins, the lcd 15 /ks 15 through lcd 0 /ks 0 pins are also used as key source signal output pins. the key source signals and lcd segment signals are output by means of time-division multiplexing. for the details on the general-purpose output ports, refer to 15. general-purpose port . for the details on the key source signals, refer to 22. key source controller/decoder . the following subsections 21.2.1 through 21.2.5 outlines the function of each block of the lcd controller/ driver. figure 21-2. common signal output, segment signal output, and display dot 21.2.1 lcd segment register the lcd segment register sets dot data that is used to turn on/off the lcd. because this register is mapped on the data memory, it can be controlled by any data memory manipulation instruction. when the segment signal output pins are used as general-purpose output port pins, this registers sets output data. for details, refer to 21.3 . com 1 pin display dot segment signal output pin (lcd n ) com 0 pin
m pd17016, 17017 260 21.2.2 common signal output timing control block the common signal output timing control block controls the common signal output timing of the com 1 and com 0 pins. these pins output a low level when the lcd is not displayed. whether the lcd is displayed or not is selected by the lcd mode select register (rf address 10h). for details, refer to 21.4 . 21.2.3 segment signal/key source signal output timing control block the segment signal/key source signal output timing control block controls the segment signal output timing of the lcd 29 /p0f 3 through lcd 0 /ks 0 pins. these pins output a low level when the lcd is not displayed. whether the lcd is displayed or not is selected by the lcd mode select register. the segment signal/key source signal output timing control block controls the timing of the segment and key source signals output from the lcd 15 /ks 15 through lcd 0 /ks 0 pins. whether the key source signals are used or not is selected by the lcd mode select register. for details, refer to 21.4 . 21.2.4 segment signal/general-purpose port select block the segment signal/general-purpose port select block selects whether each segment signal output pin is used for lcd display (to output a segment signal) or as a general-purpose output port pin. this selection is made by using the software macro supplied with the device file. for details, refer to 21.4 . 21.2.5 key source signal output control block the key source signal output control block sets the key source output data that are output from the lcd 15 / ks 15 through lcd 0 /ks 0 pins and detects key input timing. the key source signal output data are set by the key source data register (ksr: peripheral address 42h) via the data buffer. to use the key source signals, the p0d 3 /adc 5 through p0d 0 /adc 2 pins are used as key input pins. for details, refer to 22. key source controller/decoder .
m pd17016, 17017 261 21.3 lcd segment register the lcd segment register specifies whether each dot on the lcd is turned on/off. 21.3.1 configuration of lcd segment register figure 21-3 shows the location of the lcd segment register on the data memory. figure 21-4 shows the configuration of the lcd segment register. figure 21-3. location of lcd segment register on data memory note bank3 is not provided on the m pd17016. figure 21-4. configuration of lcd segment register column address 0 1 2 3 4 5 6 7 0 row address bank1 7 data memory bank2 7 bank3 note 7 system register 123456789abcdef bank0 dbf 0123 456789abcdef lcd segment register address symbol 60h lcdd0 61h lcdd1 62h lcdd2 63h lcdd3 64h lcdd4 65h lcdd5 66h lcdd6 67h lcdd7 68h lcdd8 69h lcdd9 6ah lcdd10 6bh lcdd11 6ch lcdd12 6dh lcdd13 6eh lcdd14 6fh lcd segment register b 3 b 2 b 1 b 0 lcdd0 nothing is allocated to this address. this address cannot be used as a data memory area.
m pd17016, 17017 262 21.3.2 function of lcd segment register figure 21-5 shows the relation of 1 nibble (4 bits) of the lcd segment register and lcd display dots. as shown in this figure, 1 nibble of the lcd segment register can set display data (on/off data) of 4 dots. the lcd display dot corresponding to a bit that is set to 1 is turned on, and the dot corresponding to a bit that is reset to 0 is turned off. the lcd segment register also sets output data when the segment signal output pins are used as output port pins. figure 21-6 shows the relation between each lcd segment register and lcd display dots that are turned on/off. figure 21-5. relation of 1 nibble of lcd segment register and lcd display dots lcd segment register address bit b 3 b 2 b 1 b 0 m com 1 pin com 0 pin b 3 b 2 lcd n pin b 1 b 0 lcd nC1 pin
m pd17016, 17017 263 [memo]
m pd17016, 17017 264 figure 21-6. relation among lcd display dots, ports 0e and 0f, key source output, and each data setting register (1/2) key source general- purpose port key source data register (peripheral address) bit bit port register (ram address) lcd function pin no. lcd segment register (ram address) bit b 3 lcdd14 (6eh) b 2 (45) b 1 b 0 (46) b 3 lcdd13 (6dh) b 2 (47) b 1 b 0 (48) b 3 lcdd12 (6ch) b 2 (49) b 1 b 0 (50) b 3 lcdd11 (6bh) b 2 (51) b 1 b 0 (52) b 3 lcdd10 (6ah) b 2 (53) b 1 b 0 (54) b 3 lcdd9 (69h) b 2 (55) b 1 b 0 (56) b 3 lcdd8 (68h) b 2 (57) b 1 b 0 (58) b 3 p0f (6dh) b 2 b 1 b 0 b 3 p0e (6bh) b 2 b 1 b 0 b 3 b 1 b 3 b 1 b 3 b 1 b 3 b 1 b 3 b 1 b 3 b 1 b 3 b 1 b 2 b 0 b 2 b 0 b 2 b 0 b 2 b 0 b 2 b 0 b 2 b 0 b 2 b 0 l c d 29 l c d 28 l c d 27 l c d 26 l c d 25 l c d 24 l c d 23 l c d 22 l c d 21 l c d 20 l c d 19 l c d 18 l c d 17 l c d 16 com 1 pin (43) com 0 pin (44) p 0 f 3 p 0 f 2 p 0 f 1 p 0 f 0 p 0 e 3 p 0 e 2 p 0 e 1 p 0 e 0
m pd17016, 17017 265 figure 21-6. relation among lcd display dots, ports 0e and 0f, key source output, and each data setting register (2/2) b 3 lcdd0 (60h) b 2 (73) b 1 b 0 (74) b 3 b 1 b 3 b 1 b 3 b 1 b 3 b 1 b 3 b 1 b 3 b 1 b 3 b 1 b 2 b 0 b 2 b 0 b 2 b 0 b 2 b 0 b 2 b 0 b 2 b 0 b 2 b 0 l c d 13 l c d 12 l c d 11 l c d 10 l c d 9 l c d 8 l c d 7 l c d 6 l c d 5 l c d 4 l c d 3 l c d 2 l c d 1 l c d 0 b 3 lcdd1 (61h) b 2 (71) b 1 (72) b 3 lcdd2 (62h) b 2 (69) b 1 (70) b 3 lcdd3 (63h) b 2 (67) b 1 (68) b 3 lcdd4 (64h) b 2 (65) b 1 (66) b 3 lcdd5 (65h) b 2 (63) b 1 (64) b 3 lcdd6 (66h) b 2 (61) b 1 (62) b 3 lcdd7 (67h) b 2 (59) b 1 (60) b 0 b 0 b 0 b 0 b 0 b 0 b 0 correspondence of segment register bit b 3 b 1 b 2 b 0 l c d 15 l c d 14 k s 15 k s 14 k s 13 k s 12 k s 11 k s 10 k s 9 k s 8 k s 7 k s 6 k s 5 k s 4 k s 3 k s 2 k s 1 k s 0 b 15 b 14 b 13 b 12 b 11 b 10 b 9 b 8 ksr (42h) b 7 b 6 b 5 b 4 b 3 b 2 b 1 b 0
m pd17016, 17017 266 21.4 output timing control blocks and segment/port select block 21.4.1 configuration of output timing control blocks and segment/port select block figure 21-7 shows the configuration of the common signal and segment signal/key source signal output timing control block and segment signal/general-purpose output port select block. figure 21-7. configuration of timing control blocks and port select block address bit flag symbol control register 10h b 3 0 b 2 0 b 1 b 0 1 0 segment signal timing control b 0 b 1 lcd segment register v dd 1 0 segment signal timing control b 2 b 3 lcd segment register v dd basic clock for timing control v dd b 0 b 1 lcd segment register b 0 b 1 lcd segment register key source data register segment signal/ key source signal timing control v dd v dd segment signal timing control port data common signal timing control v dd com 1 com 0 setting by software macro lcd 29 /p0f 3 lcd 28 /p0f 2 lcd 26 /p0f 0 lcd 25 /p0e 3 lcd 22 /p0e 0 lcd 21 lcd 16 lcd 0 /ks 0 lcd 15 /ks 15 k s e n l c d e n
m pd17016, 17017 267 21.4.2 function of segment signal/general-purpose output port select block the segment signal/general-purpose output port select block specifies whether each pin is used as a segment signal output pin or a general-purpose output port pin, by using the software macro supplied with the device file (refer to table 21-1. software macros setting ports (p0e and p0f) ). for the details on the general-purpose output port, refer to 15. general-purpose port . table 21-1. software macros setting ports (p0e and p0f) function macro format uses lcd 22 /p0e 0 -lcd 25 /p0e 3 pins as general-purpose output port set1_p0eon uses lcd 26 /p0f 0 -lcd 29 /p0f 3 pins as general-purpose output port set1_p0fon uses lcd 22 /p0e 0 -lcd 25 /p0e 3 pins and lcd 26 /p0f 0 -lcd 29 /p0f 3 pins as general-purpose set2_p0eon_p0fon output port uses lcd 22 /p0e 0 -lcd 25 /p0e 3 pins as lcd segment signal output pins clr1_p0eon uses lcd 26 /p0f 0 -lcd 29 /p0f 3 pins as lcd segment signal output pins clr1_p0fon uses lcd 22 /p0e 0 -lcd 25 /p0e 3 and lcd 26 /p0f 0 -lcd 29 /p0f 3 pins as lcd segment signal clr2_p0eon_p0fon output pins uses lcd 22 /p0e 0 -lcd 25 /p0e 3 pins as lcd segment signal output pins and lcd 26 /p0f 0 - init_not_p0eon_p0fon lcd 29 /p0f 3 pins as general-purpose output port uses lcd 22 /p0e 0 -lcd 25 /p0e 3 pins as general-purpose output port and lcd 26 /p0f 0 -lcd 29 / init_p0eon_not_p0fon p0f 3 pins as lcd segment signal output pins caution if the above macros are used, the contents of the window register are destroyed. if the above macros are immediately follow an embedded macro instruction, an object error occurs when the source file is assembled and loaded to the in-circuit emulator. if an embedded macro is used before the above macros, insert a comment statement in between them. 21.4.3 functions of output timing control blocks the output timing control blocks control the timing of the common and segment signals for lcd display and the timing of the key source and segment signals when the key source controller/decoder is used. the common and segment signals are output when the lcden flag of the lcd mode select register is 1. in other words, all the lcd display dots can be turned off by the lcden flag. when all the lcd display dots have been turned off, the common and segment signals output a low level. the key source signals are output when the ksen flag of the lcd mode select register is 1. therefore, use of the key source signal can be specified by the ksen flag. 21.4.4 explains the configuration and function of the lcd mode select register. 21.4.5 shows the output waveforms of the common and segment signals. for the details on the key source controller/decoder, refer to 22. key source controller/decoder .
m pd17016, 17017 268 21.4.4 configuration and function of lcd mode select register the lcd mode select register turns on/off all the lcd display dots, and specifies output of the key source signals. the configuration and function of this register are illustrated below. name flag symbol b 3 0 b 2 0 b 1 b 0 address 10h read/ write r/w 0 1 turns on/off all lcd display dots power-on clock stop ce 000 0 0 0 lcd mode select register fixed to "0" 0 1 l c d e n k s e n display off (all segment and common signals are low) display on sets output of key source signal key source off key source on on reset retained
m pd17016, 17017 269 21.4.5 output waveforms of common and segment signals figures 21-8 and 21-9 show the output waveforms of the common and segment signals. figure 21-8 shows the output waveform with the key source signals not output, and figure 21-9 shows the output waveform with the key source signals output. as shown in figure 21-8, the lcd driver outputs signals with a frame frequency of 125 hz at 1/2 duty, 1/2 bias (voltage average mode). as the common signals, three levels of voltages (0, 1/2 v dd , and v dd ) each having a phase difference of 1/4 from the others are output from the com 1 and com 0 pins. therefore, voltages in a range of 1/2v dd 1/2 v dd are output. this display mode is called 1/2 bias drive mode. as the segment signals, two levels (0, v dd ) of voltages each having a phase corresponding to a display dot are output from each segment signal output pin. because two display dots (a and b) are turned on/off by one segment pin as shown in figure 21-8, four types of phases <1> through <4> shown in figure 21-8 are output by combination of dots a and b, and on and off. dots a and b are turned on when the potential difference between the common and segment signals reaches v dd . the duty factor at which each of dots a and b is turned on is 1/2, and the frequency of the lcd clock is 250 hz. this display mode is called 1/2 duty drive mode, and the frame frequency is 125 hz.
m pd17016, 17017 270 figure 21-8. output waveforms of common and segment signals (with key source signals not output) v dd 1/2v dd gnd v dd 1/2v dd gnd com 1 pin com 0 pin each segment pin <1> a = off, b = off <2> a = on, b = off <3> a = off, b = on <4> a = on, b = on a = on a = on a = on b = on b = on b = on a = on b = on a = on b = on a = on b = on frame frequency 125 hz each segment signal output pin (lcd n ) dot a dot b com 1 pin com 0 pin 2 ms 2 ms 2 ms 2 ms 2 ms 2 ms common signals
m pd17016, 17017 271 figure 21-9. output waveforms of common and segment signals (with key source signals output) v dd 1/2v dd gnd v dd 1/2v dd gnd com 1 pin com 0 pin common signals each segment pin (pin outputting "1" as key source) <1> a = off, b = off <2> a = on, b = off <3> a = off, b = on <4> a = on, b = on a = on a = on a = on b = on b = on b = on a = on b = on a = on b = on a = on b = on <1> a = off, b = off <2> a = on, b = off <3> a = off, b = on <4> a = on, b = on a = on a = on a = on b = on b = on b = on a = on b = on a = on b = on a = on b = on 2 ms 2 ms 2 ms 2 ms 2 ms 2 ms each segment pin (pin outputting "0" as key source) each segment signal output pin (lcd n ) dot a dot b com 1 pin com 0 pin
m pd17016, 17017 272 21.5 using lcd controller/driver figure 21-10 shows an example of wiring an lcd panel. an example of a program that turns on a 7-segment lcd panel by using the lcd 0 through lcd 3 pins as shown in figure 21-10 is shown below. example pmn0 mem 0.01h ; preset memory number and bk data storage area ch flg dbf0.1 ; symbol definition of least significant bit of dbf as ch display flag lcddata: ; display table data ; b 3 b 2 b 1 b 0 b 3 b 2 b 1 b 0 ; corresponds to lcd segment register ; fbegdcaC ; corresponds to lcd group register dw 0000000000000000b ; blank dw 0000000001000100b ; 1 dw 0000000001111010b ; 2 dw 0000000001011110b ; 3 dw 0000000011010100b ; 4 dw 0000000010011110b ; 5 dw 0000000010111110b ; 6 dw 0000000011000110b ; 7 dw 0000000011111110b ; 8 dw 0000000011011110b ; 9 dw 0000000011111010b ; a dw 0000000011111110b ; b dw 0000000010101010b ; c dw 0000000011101110b ; d dw 0000000010111010b ; e dw 0000000010110010b ; f clr2_p0eon_p0fon ; software macro mov rpl, #1110b mov ar3, #.dl.lcddata shr 12 and 0fh mov ar2, #.dl.lcddata shr 8 and 0fh mov ar1, #.dl.lcddata shr 4 and 0fh mov ar0, #.dl.lcddata and 0fh add ar0, pmn0 addc ar1, #0 addc ar2, #0 addc ar3, #0 movt dbf, @ar mov rph, #0000b mov rpl, #0000b skge pmn0, #0ah set1 ch ld lcdd1, dbf1 ld lcdd0, dbf0 set1 lcden
m pd17016, 17017 273 figure 21-10. example of wiring of lcd panel l c d 25 l c d 24 l c d 23 l c d 22 1a 1g 1d 1 e 1 c 1 b 1 f a l c d 21 l c d 20 l c d 18 l c d 17 2a 2g 2d 2 e 2 c 2 b 2 f b l c d 15 l c d 14 l c d 13 3a 3g 3 e 3 c 3 b 3 f l c d 19 l c d 12 l c d 16 c 3d l c d 11 l c d 10 l c d 9 4a 4g 4 e 4 c 4 b 4 f l c d 8 d 4d e f g l c d 7 l c d 6 am pm mhz khz l c d 5 l c d 4 l c d 3 l c d 2 l c d 1 5a 5g 5 e 5 c 5 b 5 f l c d 0 5d ch l c d 26 l c d 27 fm mw sw lw l c d 29 l c d 28 c o m 0 c o m 1 l c d 29 segment pin common pin l c d 28 l c d 27 l c d 26 l c d 25 l c d 24 l c d 23 l c d 22 l c d 21 l c d 20 l c d 19 l c d 18 l c d 17 l c d 16 l c d 15 l c d 14 l c d 13 l c d 12 l c d 11 l c d 10 l c d 9 l c d 8 l c d 7 l c d 6 l c d 5 l c d 4 l c d 3 l c d 2 l c d 1 l c d 0 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 43 44 com 1 com 0 fm sw mw lw 1f 1b 1e 1g 1d 1c 1a a b 2f 2b 2e 2g 2d 2c 2a : 3f 3b 3e 3g 3d 3c 3a c 4f 4b 4e 4g 4d 4c 4a d fe g pm khz am mhz 5f 5b 5e 5g 5d 5c 5a ch correspondence between segment and common pins on lcd panel
m pd17016, 17017 274 21.6 status on reset 21.6.1 on power-on reset the lcd 29 /p0f 3 through lcd 0 /ks 0 pins are specified as lcd segment signal output pins, and output a low level. the com 1 and com 0 pins output a low level. therefore, the lcd display is turned off. 21.6.2 on execution of clock stop instruction the lcd 29 /p0f 3 through lcd 0 /ks 0 pins are specified as lcd segment signal output pins, and output a low level. the com 1 and com 0 pins output a low level. therefore, the lcd display is turned off. 21.6.3 on ce reset of the lcd 29 /p0f 3 through lcd 0 /ks 0 pins, those that are specified as segment signal output pins output segment signals, and those that are specified as general-purpose output port pins retain the current output value. the com 1 and com 0 pins output common signals. 21.6.4 in halt status of the lcd 29 /p0f 3 through lcd 0 /ks 0 pins, those that are specified as segment signal output pins output segment signals, and those that are specified as general-purpose output port pins retain the current output value. the com 1 and com 0 pins output common signals.
m pd17016, 17017 275 22. key source controller/decoder the key source controller/decoder can configure a key matrix of up to 64 keys by outputting key source signals from the pins that also output lcd segment signals. whether key source signals or lcd segment signals are output from the pins is controlled by means of time-division multiplexing. 22.1 configuration of key source controller/decoder figure 22-1 shows the configuration of the key source controller/decoder. as shown in the figure, the key source controller/decoder consists of a segment signal/key source signal timing control block, key source data register, key input control block, and p0d port register. the following section 22.2 outlines the function of each block. figure 22-1. block diagram of key source controller/decoder control register data buffer key source data register (ksr) key source data latch lcd display data segment signal/key source signal output timing control key input control p0d port register (data memory) key matrix 16 l c d 15 / k s 15 l c d 14 / k s 14 l c d 2 / k s 2 l c d 1 / k s 1 l c d 0 / k s 0 p o d 3 / a d c 5 p o d 2 / a d c 4 p o d 1 / a d c 3 p o d 0 / a d c 2
m pd17016, 17017 276 22.2 functional outline of key source controller/decoder the key source controller/decoder can configure a key matrix of up to 64 keys by using key source signal output pins (lcd 15 /ks 15 through lcd 0 /ks 0 ) and key input pins (p0d 3 /adc 5 through p0d 0 /adc 2 ). figure 22-2 shows the example of key matrix configuration. the lcd 15 /ks 15 through lcd 0 /ks 0 pins are multiplexed with lcd segment signal output pins. therefore, the key source signals and lcd segment signals are output by means of time-division multiplexing. the following subsections 21.2.1 through 22.2.3 outline the function of each block of the key source controller/ decoder. figure 22-2. example of key matrix configuration 22.2.1 key source data register (ksr) the key source data register sets the key source output data of the pin that outputs a key source signal. data are set to the key source data register via the data buffer. when data are set to this register, the key source data are output from the lcd 15 /ks 15 through lcd 0 /ks 0 pins. for details, refer to 22.3 . 22.2.2 segment signal/key source signal output timing control block the segment signal/key source signal output timing block controls the output timing of the key source and segment signals of the lcd 29 /p0f 3 through lcd 0 /ks 0 pins. whether a key source signal is used or not is specified by the lcd mode select register. the key source signal is not output when lcd display is not used. in this case, the above pins output a low level. whether lcd display is not used or not is specified by the lcd mode select register. for details, refer to 22.4 . key source input pin key source output pin
m pd17016, 17017 277 22.2.3 key input control block and p0d port register the key input control block detects the key input signals input to the p0d 3 /adc 5 through p0d 0 /adc 2 pins in synchronization with key source signal output timing. to output the key source signals from the lcd 15 /ks 15 through lcd 0 /ks 0 pins, therefore, the p0d 3 /adc 5 through p0d 0 /adc 2 pins are used as key input pins. the key input data are read by the p0d port register (address 73h of bank0) on the data memory. because the p0d 3 /adc 5 through p0d 0 /adc 2 pins are multiplexed with the a/d converter pins, care must be exercised when using these pins as the a/d converter pins. for details, refer to 22.5 . 22.3 key source data setting block 22.3.1 configuration of key source data setting block figure 22-3 shows the configuration of the key source data setting block. figure 22-3. configuration of key source data setting block 22.3.2 function of key source data setting block the key source data setting block sets the key source data to be output from the lcd 15 /ks 15 through lcd 0 / ks 0 pins. the key source data are set to the key source data register (ksr: peripheral address 42h) via the data buffer. each bit of the key source data register corresponds to the lcd 15 /ks 15 through lcd 0 /ks 0 pins, and sets the key source data of each pin. when 1 is set to a bit of the key source data register, the pin corresponding to this bit outputs a high level as a key source signal; when the bit is reset to 0, the corresponding pin outputs a low level. for the output timing, refer to 22.4 . the following subsections 22.3.3 explains the configuration and function of the key source data register. also refer to figure 21-6 in 21. lcd controller/driver . data buffer (dbf) address symbol data 0ch dbf3 0dh dbf2 0eh dbf1 0fh dbf0 16 peripheral address 42h key source data register (ksr) key source data latch m s b l s b
m pd17016, 17017 278 22.3.3 configuration and function of key source data register (ksr) the configuration and function of the key source data register are illustrated below. name symbol address bit data data buffer dbf3 0ch dbf2 0dh dbf1 0eh dbf0 0fh b 3 b 2 b 1 b 0 b 3 b 2 b 1 b 0 b 3 b 2 b 1 b 0 b 3 b 2 b 1 b 0 transfer data 16 get can be executed put can be executed b 15 b 14 b 13 b 12 b 11 b 10 b 9 b 8 b 7 b 6 b 5 b 4 b 3 b 2 b 1 b 0 name peripheral register symbol ksr valid data peripheral address 42h peripheral hardware selects output pin of key source signal key source data register key source controller/decoder lcd 0 /ks 0 pin lcd 1 /ks 1 pin lcd 2 /ks 2 pin lcd 3 /ks 3 pin lcd 4 /ks 4 pin lcd 5 /ks 5 pin lcd 6 /ks 6 pin lcd 7 /ks 7 pin lcd 8 /ks 8 pin lcd 9 /ks 9 pin lcd 10 /ks 10 pin lcd 11 /ks 11 pin lcd 12 /ks 12 pin lcd 13 /ks 13 pin lcd 14 /ks 14 pin lcd 15 /ks 15 pin does not output key source signal outputs key source signal 0 1
m pd17016, 17017 279 22.4 output timing control blocks and segment/port select block 22.4.1 configuration of output timing control blocks and segment/port select block figure 22-4 shows the configuration of the common signal and segment signal/key source signal output timing control blocks and segment signal/general-purpose output port select block. figure 22-4. configuration of timing control blocks and port select block address bit flag symbol control register 10h b 3 0 b 2 0 b 1 b 0 b 0 b 1 lcd segment register key source data register segment signal/ key source signal timing control v dd lcd 0 /ks 0 lcd 15 /ks 15 basic clock for timing control k s e n l c d e n
m pd17016, 17017 280 22.4.2 function of output timing control blocks the output timing control blocks controls the output timing of the key source and segment signals. the lcd segment signal is output when the lcden flag of the lcd mode select register is 1. all the lcd display dots can be turned off by resetting the lcden flag to 0. at this time, a low level is output as the segment signal, and the key source signal is not output. to output the key source signal, therefore, the lcden flag must be 1. the key source signal is also output when the ksen flag of the lcd mode select register is 1. therefore, the ksen flag is used to specify whether the key source signal is used or not. to output the key source signal, therefore, the lcden and ksen flags must be 1. the following subsection 22.4.3 indicate the configuration and function of the lcd mode select register. subsection 22.4.4 shows the output waveforms of the key source and segment signals. for the relation among the common and segment signals of the lcd, and key source signal, refer to 21. lcd controller/driver .
m pd17016, 17017 281 22.4.3 configuration and function of lcd mode select register the lcd mode select register turns on/off all the lcd display dots, and specifies output of the key source signal. the configuration and function of this register are illustrated below. 22.4.4 output waveforms of segment and key source signals figure 22-5 shows the output waveforms of the key source and segment signals. as shown in the figure, the key source and segment signals are output by means of time-division multiplexing. the key source signal is output for 220 m s at intervals of 4 ms. to put it in another way, a pin corresponding to a bit of the key source data register that is set to 1 outputs a high level for 220 m s every 4 ms, and a pin corresponding to a bit of the key source data register that is reset to 0 outputs a low level for 220 m s every 4 ms. when output of the key source signal is selected (ksen flag = 1), pins that do not output key source signals (lcd 29 /p0f 3 through lcd 16 ) output the waveform shown in figure 22-5. however, a waveform of 0 is output as the key source data. name flag symbol b 3 0 b 2 0 b 1 b 0 address 10h read/ write r/w 0 1 turns on/off all lcd display dots display off (all segment and common output pins output low level) display on on reset power-on clock stop ce 000 0 0 0 lcd mode select register 0 1 selects output of key source signal key source off key source on fixed to "0" retained l c d e n k s e n
m pd17016, 17017 282 figure 22-5. output waveforms of key source and segment signals v dd 1/2v dd gnd v dd 1/2v dd gnd com 1 pin com 0 pin connon signals each segment pin (pin outputting "1" as key source) <1> a = off, b = off <2> a = on, b = off <3> a = off, b = on <4> a = on, b = on a = on a = on a = on b = on b = on b = on a = on b = on a = on b = on a = on b = on <1> a = off, b = off <2> a = on, b = off <3> a = off, b = on <4> a = on, b = on a = on a = on a = on b = on b = on b = on a = on b = on a = on b = on a = on b = on 2 ms 2 ms 2 ms 2 ms 2 ms 2 ms each segment pin (pin outputting "0" as key source) dot a dot b com 1 pin com 0 pin each segment/key source signal output pin (lcd n /ks n ) segment signal 220 s m key source signal key source signal
m pd17016, 17017 283 22.5 key input control block 22.5.1 configuration of key input control block figure 22-6 shows the configuration of the key input control block. figure 22-6. configuration of key input control block 22.5.2 function of key input control block the key input control block controls the timing to read the key input signals from the p0d 3 /adc 5 through p0d 0 / adc 2 pins and reads the key input data. figure 22-7 illustrates the key input signals and key input timing. as shown in this figure, the internal-pull down resistors of the p0d 3 /adc 5 through p0d 0 /adc 2 pins are turned off while the display data of the lcd segment is output, and turned on only for 220 m s while the key source signal is output. for the duration of 220 m s during which the key source signal is output, the input signal of each key input pin is connected to the input latch. therefore, the signal input to each key input pin can be detected in the 220 m s during which the key source signal is output. figure 22-8 shows the timing chart of the key source signal, key input signal, and key input data (p0d port register). whether a key source signal is output or not is detected by the keyj flag of the key input judge register (rf address 16h). the keyj flag is set after the key source signal has been output for 220 m s, and is reset when data has been set to the key source data register and when the content of the keyj flag has been read. by detecting the keyj flag after the key source signal data has been output to the key source data register, and then detecting the status of each key input pin after the keyj flag has been set to 1, the key can be input. the following subsection 22.5.3 explains the configuration and function of the key input judge register. address bit flag symbol control register 16h b 3 0 b 2 0 b 1 0 b 0 read & reset halt release signal keyj ff segment signal/key source signal output timing control write instruction port register (1 bit) read instruction input latch 0 1 key source timing signal adc channel select signal v dd high on resistance a/d converter p0d 3 /adc 5 p0d 2 /adc 4 p0d 1 /adc 3 p0d 0 /adc 2 k e y j
m pd17016, 17017 284 figure 22-7. key source signal and key input timing figure 22-8. timing chart of key source signal, key input signal, and key input data (p0d port register) each segment/key source signal output pin (lcd n /ks n ) dot a dot b com 1 pin com 0 pin key source signal segment signal each segment pin (pin outputting "1" as key source, a = on, b = off) h l pull down open 1 0 segment pin key input pin keyj flag key source signal 220 s 2 ms put ksr, dbf or skt 1 keyj input data is latched at this point. signal input to p0d 3 /adc 5 through p0d 0 /adc 2 pins is connected to input latch during this period. if put ksr, dbf is executed during this period, keyj flag is not set for 4 ms. put ksr, dbf or skt1 keyj 2 ms m h l input data is latched at this point. h l 1 0 h l 1 0 keyj flag is ??during this period. if value of p0d is read, status of p0d pin is read. segment pin <1> when p0d port register is ? key input pin input signal <2> when p0d port register is ? p0d port register key input pin input signal p0d port register
m pd17016, 17017 285 22.5.3 configuration and function of key input judge register the key input judge register detects the presence or absence of the key input signal latch when the lcd segment signal output pins are shared with key source signal output. the configuration and functions of this register are illustrated below. the key source data is set by setting the contents of the data buffer to the key source data register by using the put instruction. when the key source signal output data is set by the put instruction via the data buffer, the keyj flag is reset to 0. the keyj flag is also reset to 0 (read & reset) when the contents of the window register are read by the peek instruction. name flag symbol b 3 0 b 2 0 b 1 0 b 0 address 16h read/ write r & reset 0 1 detects presence/absence of latch of key input signal no key latch key latch on reset power-on clock stop ce 0000 key input judge register fixed to "0" k e y j unde- fined unde- fined
m pd17016, 17017 286 22.6 using key source controller/decoder 22.6.1 configuring key matrix figure 22-9 shows an example of configuring a key matrix. as shown in this figure, the key matrix can be configured for up to 64 keys. because the key source signal output pins also output the lcd segment signals at the same time, diode a must be used to prevent reverse flow of the lcd segment signal if a momentary switch is used. diodes b and c are used to prevent sneaking of the key source signal. use a pnp transistor as the transistor switch. the following (1) explains the points to be noted when an npn transistor is used. (2) through (4) explain the points to be noted if diodes a, b, and c are not used. figure 22-9. example of key matrix configuration 78 77 76 75 74 73 72 71 70 69 68 67 66 65 60 59 to lcd panel configuration of each switch ks a b k momentary switch ks k ks k alternate switch ks k c or ks k c ks k diode switch ks k
m pd17016, 17017 287 (1) notes on using npn transistor switch when an npn transistor switch is used, the low level may not be accurately read as illustrated in the figure below. if ks is low and a high level is input to the base of the transistor in the figure on the left, voltage v k input to k is as follows. r b v k = (v dd C v be ) r a + r b a low level must be input to k at this time because ks is low. however, the voltage input to k changes depending on r a and r b , as indicated by the above expression. therefore, a low level may not be input depending on the values of r a and r b . (2) notes when diode a is not used an example of a circuit where diode a is missing is shown below. suppose switches sw1 and sw2 are on, ks 15 outputs a high level, and ks 14 outputs a low level, as shown below. if diode a is missing, currents i 1 and i 2 indicated by the dotted lines flow. consequently, the high level of ks 15 and low level of ks 14 are not output correctly because of i 2 , and the key input data of k 3 cannot be accurately read. if ks 15 and ks 14 are used to output lcd segment signals, the lcd cannot be turned on/off correctly. -------------------------------- ks internal resistor r b k r a v dd high low k 2 k 3 ks 14 ks 15 lcd lcd sw1 sw2 i 1 i 2 low high
m pd17016, 17017 288 (3) notes when diode b is not used an example of a circuit where diode b is not used is shown below. suppose switches sw1, sw2, and sw4 are on, and ks 7 outputs a high level, as shown below. if diode b is missing, currents i 1 and i 2 flow as indicated by the dotted lines. consequently, a high level is input to k 2 because of i 2 despite that switch sw3 is off, and it is judged that sw3 is on. (4) note when diode c is not used an example of a circuit where diode c is not used is shown below. suppose switches sw2, sw3, and sw4 are on, and ks 8 outputs a high level, as shown below. if diode c is missing, currents i 1 , i 2 , and i 3 flow as indicated by the dotted lines. consequently, a high level is input to k 2 because of i 2 despite the fact that switch sw1 is off, and it is judged that sw1 is on. moreover, ks 8 cannot output a high level correctly because of i 3 . k 2 k 3 ks 7 ks 8 sw2 sw4 i 1 high low sw3 sw1 i 2 k 2 k 3 ks 7 ks 8 sw2 sw4 i 1 low sw3 sw1 i 2 i 3 high
m pd17016, 17017 289 22.6.2 reading alternate switches and diode switches here is a program example. example to read statuses of alternate and diode switches of lcd 15 /ks 15 through lcd 8 /ks 8 pins to addresses 20h through 27h of bank0 of data memory ks8 nibble8 0.20h key_in mem 0.73h ; p0d port register key_load: set2 lcden, ksen ; lcd segment and key source signal output mov dbf3, #0000b ; sets key source data mov dbf2, #0001b ; outputs low level from ks 8 mov dbf1, #0000b mov dbf0, #0000b mov ixm, #0000b mov ixl, #0000b mov rph, #0000b mov rpl, #0000b kscan: put ksr, dbf ; outputs signal of key source data loop: skf1 keyj ; determines if key input is latched br kcheck processing a ; waits until key input is latched br loop kcheck: mov rpl#.dm.key_in shr 3 and 0eh set1 ixe st ks8, key_in ; stores key input data to data memory clr1 ixe mov rpl, #0000b inc ix add dbf2, dbf2 ; updates value of key source data and add dbf3, dbf3 ; scans key again skt1 cy ; determines if all key source lines are input br kscan key_end: ; end of input
m pd17016, 17017 290 22.6.3 inputting momentary switch by binary search the key source controller/decoder requires 4 ms to input the key of one key source signal line. to input the keys of 16 key source signals, therefore, it takes 64 ms. it is therefore convenient if the binary search method explained in (1) and (2) below is used. (1) flowchart when ks 7 through ks 0 are used as key source signals of momentary switch start ; sets key source controller end ; sets offset address of table storing key source data to ra ar ksdata+ra dbf @ ar ksr dbf keyj = 1? n y ; waits until data is latched to key input latch (4 ms) ; outputs key source data at offset address specified by ra ; saves key input data to rb initialization ra 0000b rb p0d port register ra = rb = 0? y n ; if key input data and ra are "0", inputs all keys again because no ; key is input ; if ra is less than "7", updates ra and continues binary search ra ra+ra rb = 0? n y ra > 7? y n ; if ra is greater than "7", input of one key source ends and waits for ; chattering ra ra+1 rb = 0? y n ; if there is no key input data, checks all keys again ; even if this chattering wait is missing, chattering occurs for 4 ms chattering wait ; inputs key input determined by binary search to rc again dbf ksr ksr dbf keyj = 1? n y ; if rc = 0, occurrence of chattering is determined, and keys are input ; from beginning rc p0d port register rc = 0? y n ; stores key input data before chattering to rb, data after chattering ; to rc, and key source data to ra checking of key data
m pd17016, 17017 291 example of table data for binary search table data (key source data) b 15 b 14 b 13 b 12 b 11 b 10 b 9 b 8 b 7 b 6 b 5 b 4 b 3 b 2 b 1 b 0 0000b 0001b 0010b 0011b 0100b 0101b 0110b 0111b 1000b 1001b 1010b 1011b 1100b 1101b 1110b 1111b (2) program example ra mem 0.1ah ; general-purpose work register rb mem 0.1bh ; general-purpose work register rc mem 0.1ch ; general-purpose work register key_in mem 0.73h ; p0d port register ksdata: ; kkkkkkkkkkkkkkkk ; ssssssssssssssss ; 1111119876543210 ; 543210 dw 0000000011111111b ; ra = 0 dw 0000000011110000b ; ra = 1 dw 0000000000001100b ; ra = 2 dw 0000000000110000b ; ra = 3 dw 0000000000000010b ; ra = 4 dw 0000000000001000b ; ra = 5 dw 0000000000100000b ; ra = 6 dw 0000000010000000b ; ra = 7 dw 0000000000000001b ; ra = 8 dw 0000000000000010b ; ra = 9 dw 0000000000000100b ; ra = 10 dw 0000000000001000b ; ra = 11 dw 0000000000010000b ; ra = 12 dw 0000000000100000b ; ra = 13 dw 0000000001000000b ; ra = 14 dw 0000000010000000b ; ra = 15 key_load: set2 lcden, ksen ; lcd segment and key source signal output start: mov ra, #0000b shift address (ra)
m pd17016, 17017 292 kscan: mov ar3, #.dl.ksdata shr 0ch and 0fh mov ar2, #.dl.ksdata shr 8 and 0fh mov ar1, #.dl.ksdata shr 4 and 0fh mov ar0, #.dl.ksdata and 0fh mov rpl, #.dl.ar0 shr 3 and 0eh add ar0, ra addc ar1, #0 addc ar2, #0 addc ar3, #0 mov rpl, #0 movt dbf, @ar ; reads table data put ksr, dbf ; outputs signal of key source data loop1: skf1 keyj ; determines if key input is latched br kcheck processing a ; waits until key input is latched br loop1 kcheck: mov prl, #.dm.rb shr 3 and 0eh ld rb, key_in ; stores key input data to rb skne ra, #0000b ; all keys are checked? ske rb, #0000b br key input br start ; there is no key input key input: sklt ra, ra ; key sources are narrowed down to one? br lastchk ; if not, updates value of ra, and scans keys again add ra, ra ske rb, #0000b add ra, #0001b br kscan lastchk: mov rpl, #0 skne rb, #0000b ; key input to one key source? br start ; if not, it is determined that chattering occurs chattering wait
m pd17016, 17017 293 loop2: skf1 keyj ; determines if key input is latched br keydec processing b ; waits until key input is latched br loop2 keydec: mov rpl, #.dm.rc shr 3 and 0eh ld rc, key_in ; stores key input data to latch set2 cap, z ; compares key input data after chattering with key input sub rc, rb ; data before chattering wait skt1 z br start ; if data differ key_end: ; stores key source data to ra, key input data before ; chattering to rb, and key input data after chattering to rc
m pd17016, 17017 294 22.7 status on reset 22.7.1 on power-on reset the lcd 29 /p0f 3 through lcd 0 /ks 0 pins are specified as the lcd segment signal output pins and output a low level (display off). a low level is output as the key source signal. 22.7.2 on execution of clock stop instruction the lcd 29 /p0f 3 through lcd 0 /ks 0 pins are specified as the lcd segment signal output pins and output a low level (display off). a low level is output as the key source signal. 22.7.3 on ce reset the output data is retained as is if the key source signal is being output. 22.7.4 in halt status the output data is retained as is if the key source signal is being output. if key input is specified as a halt status releasing condition, the halt status is released when a high level is input to the p0d 3 /adc 5 through p0d 0 /adc 2 pins. if the key source controller is used, however, the halt status is released only by a high level that is input within 220 m s during which the key source data is output. to release the halt status by key input by using the key source controller, do not use the p0d 3 /adc 5 through p0d 0 /adc 2 pins for the a/d converter. for an explanation of how to release the halt status by key input, refer to 12.4 halt function .
m pd17016, 17017 295 23. instruction set 23.1 outline of instruction set b 14 -b 11 b 15 01 bin hex 0000 0 add r, m add m, #n4 0001 1 sub r, m sub m, #n4 0010 2 addc r, m addc m, #n4 0011 3 subc r, m subc m, #n4 0100 4 and r, m and m, #n4 0101 5 xor r, m xor m, #n4 0110 6 or r, m or m, #n4 0111 7 inc ar inc ix rorc r movt dbf, @ar push ar pop ar get dbf, p put p, dbf peek wr, rf poke rf, wr br @ar call @ar ret retsk reti ei di stop s halt h nop 1000 8 ld r, m st m, r 1001 9 ske m, #n4 skge m, #n4 1010 a mov @r, m mov m, @r 1011 b skne m, #n4 sklt m, #n4 1100 c br addr (page 0) call addr (page 0) 1101 d br addr (page 1) mov m, #n4 1110 e br addr (page 2) skt m, #n 1111 f br addr (page 3) skf m, #n
m pd17016, 17017 296 23.2 legend ar : address register asr : address stack register indicated by stack pointer addr : program memory address (low-order 11 bits) bank : bank register cmp : compare flag cy : carry flag dbf : data buffer h : halt release condition intef : interrupt enable flag intr : register automatically saved to stack when interrupt occurs intsk : interrupt stack register ix : index register mp : data memory row address pointer mpe : memory pointer enable flag m : data memory address indicated by m r , m c m r : data memory row address (high-order) m c : data memory column address (low-order) n : bit position (4 bits) n4 : immediate data (4 bits) page : page (bit 11 of program counter: m pd17016) (bits 11 and 12 of program counter: m pd17017) pc : program counter p : peripheral address p h : peripheral address (high-order 3 bits) p l : peripheral address (low-order 4 bits) r : general register column address rf : register file address r fr : register file address (high-order 3 bits) n fc : register file address (low-order 4 bits) sp : stack pointer s : stop release condition wr : window register ( ) : contents addressed by
m pd17016, 17017 297 23.3 instruction set list instructions mnemonic operand operation instruction code op code operand add add r, m (r) (r) + (m) 00000 m r m c r m, #n4 (m) (m) + n4 10000 m r m c n4 addc r, m (r) (r) + (m) + cy 00010 m r m c r m, #n4 (m) (m) + n4 + cy 10010 m r m c n4 inc ar ar ar + 1 00111 000 1001 0000 ix ix ix + 1 00111 000 1000 0000 subtract sub r, m (r) (r) C (m) 00001 m r m c r m, #n4 (m) (m) C n4 10001 m r m c n4 subc r, m (r) (r) C (m) C cy 00011 m r m c r m, #n4 (m) (m) C n4 C cy 10011 m r m c n4 logical or r, m (r) (r) (m) 00110 m r m c r operation m, #n4 (m) (m) n4 10110 m r m c n4 and r, m (r) (r) (m) 00100 m r m c r m, #n4 (m) (m) n4 10100 m r m c n4 xor r, m (r) (r) (m) 00101 m r m c r m, #n4 (m) (m) n4 10101 m r m c n4 judge skt m, #n cmp 0, if (m) n = n, then skip 11110 m r m c n skf m, #n cmp 0, if (m) n = 0, then skip 11111 m r m c n compare ske m, #n4 (m) C n4, skip if zero 01001 m r m c n4 skne m, #n4 (m) C n4, skip if not zero 01011 m r m c n4 skge m, #n4 (m) C n4, skip if not borrow 11001 m r m c n4 sklt m, #n4 (m) C n4, skip if borrow 11011 m r m c n4 rotate rorc r cy ? (r) b3 ? (r) b2 ? (r) b1 ? (r) b0 00111 000 0111 r transfer ld r, m (r) (m) 01000 m r m c r st m, r (m) (r) 11000 m r m c r mov @r, m if mpe = 1: (mp, (r)) (m) 01010 m r m c r if mpe = 0: (bank, m r , (r)) (m) m, @r if mpe = 1: (m) (mp, (r)) 11010 m r m c r if mpe = 0: (m) (bank, m r , (r)) m, #n4 (m) n4 11101 m r m c n4 movt dbf, @ar sp sp C 1, asr pc, pc ar, 00111 000 0001 0000 dbf (pc), pc asr, sp sp + 1 push ar sp sp C 1, asr ar 00111 000 1101 0000 pop ar ar asr, sp sp + 1 00111 000 1100 0000 peek wr, rf wr (rf) 00111 rf r 0011 rf c caution the program memory addresses that can be specified by the address register range as follows: m pd17016: 0000h through 00ffh m pd17017: 0000h through 1efbh
m pd17016, 17017 298 instructions mnemonic operand operation instruction code op code operand transfer poke rf, wr (rf) wr 00111 rf r 0010 rf c get dbf, p dbf (p) 00111 p h 1011 p l put p, dbf (p) dbf 00111 p h 1010 p l branch br addr note note addr @ar pc ar 00111 000 0100 0000 subroutine call addr sp sp C 1, asr pc 11100 addr pc 11 0, pc 10 C 0 addr @ar sp sp C 1, asr pc 00111 000 0101 000 pc ar ret pc asr, sp sp + 1 00111 000 1110 0000 retsk pc asr, sp sp + 1 and skip 00111 001 1110 0000 reti pc asr, intr intsk, sp sp + 1 00111 010 1110 0000 interrupt ei intef 1 00111 000 1111 0000 di intef 0 00111 001 1111 0000 others stop s stop 00111 010 1111 s halt h halt 00111 011 1111 h nop no operation 00111 100 1111 0000 note the operation and op code of br addr of the m pd17016 and m pd17017 are as follows. (a) m pd17016 mnemonic operand operation op code br addr pc 10 C 0 addr, page 0 01100 pc 10 C 0 addr, page 1 01101 (b) m pd17017 mnemonic operand operation op code br addr pc 10 C 0 addr, page 0 01100 pc 10 C 0 addr, page 1 01101 pc 10 C 0 addr, page 2 01110 pc 10 C 0 addr, page 3 01111 caution the program memory addresses that can be specified by the address register range as follows: m pd17016: 0000h through 00ffh m pd17017: 0000h through 1efbh
m pd17016, 17017 299 23.4 assembler (as17k) embedded macroinstruction legend flag n: flg symbol n : bit number < > : can be omitted mnemonic operand operation n embedded sktn flag 1, ... flag n if (flag 1) to (flag n) = all 1, then skip 1 n 4 macro skfn flag 1, ... flag n if (flag 1) to (flag n) = all 0, then skip 1 n 4 setn flag 1, ... flag n (flag 1) to (flag n) 11 n 4 clrn flag 1, ... flag n (flag 1) to (flag n) 01 n 4 notn flag 1, ... flag n if (flag n) = 0, then (flag n) 11 n 4 if (flag n) = 1, then (flag n) 0 initflg flag 1, if description = not flag n, then (flag n) 01 n 4 ... < flag n> if description = flag n, then (flag n) 1 bankn (bank) n note note 0 n 2: m pd17016 0 n 3: m pd17017
m pd17016, 17017 300 23.5 software macroinstructions 23.5.1 beep output software macro item macro format function controls beep output beepon200 outputs 200 hz beepon1k outputs 1 khz beepon3k outputs 3 khz beepoff stops beep output caution if the above macros are used, the contents of the window register are destroyed. if an embedded macro instruction is used immediately before the above macro instructions, an object error occurs when the source file is assembled and then loaded to the in-circuit emulator. to use an embedded macro instruction immediately before the above macro instructions, insert a comment statement between them. 23.5.2 flag manipulation software macro item macro format function detects int 0 pin status skt1_int0 skips next instruction if high level is input to int 0 pin skf1_int0 skips next instruction if low level is input to int 0 pin sets interrupt enable flag set1_iptm enables timer interrupt set1_ip0 enables int 0 pin interrupt set2_iptm_ip0 enables timer interrupt and int 0 pin interrupt clr1_iptm disables timer interrupt clr1_ip0 disables int 0 pin interrupt clr2_iptm_ip0 disables timer interrupt and int 0 pin interrupt init_not_iptm_ip0 disables timer interrupt and enables int 0 pin interrupt init_iptm_not_ip0 enables timer interrupt and disables int 0 pin interrupt resets interrupt request flag clr1_irqtm note resets timer interrupt request clr1_irq0 note resets int 0 pin interrupt request note while any of these macros is executed, any other interrupt request cannot be acknowledged. for details, refer to 10.11 notes on using interrupt . caution if the above macros are used, the contents of the window register are destroyed. if an embedded macro instruction is used immediately before the above macro instructions, an object error occurs when the source file is assembled and then loaded to the in-circuit emulator. to use an embedded macro instruction immediately before the above macro instructions, insert a comment statement between them.
m pd17016, 17017 301 item macro format function set1_p0eon uses lcd 22 /p0e 0 -lcd 25 /p0e 3 pins as general-purpose output port set1_p0fon uses lcd 26 /p0f 0 -lcd 29 /p0f 3 pins as general-purpose output port set2_p0eon_p0fon uses lcd 22 /p0e 0 -lcd 25 /p0e 3 pins and lcd 26 /p0f 0 -lcd 29 / p0f 3 pins as general-purpose output port clr1_p0eon uses lcd 22 /p0e 0 -lcd 25 /p0e 3 pins as lcd segment signal output pins clr1_p0fon uses lcd 26 /p0f 0 -lcd 29 /p0f 3 pins as lcd segment signal output pins clr2_p0eon_p0fon uses lcd 22 /p0e 0 -lcd 25 /p0e 3 and lcd 26 /p0f 0 -lcd 29 /p0f 3 pins as lcd segment signal output pins init_not_p0eon_p0fon uses lcd 22 /p0e 0 -lcd 25 /p0e 3 pins as lcd segment signal output pins and lcd 26 /p0f 0 -lcd 29 /p0f 3 pins as general- purpose output port init_p0eon_not_p0fon uses lcd 22 /p0e 0 -lcd 25 /p0e 3 pins as general-purpose output port and lcd 26 /p0f 0 -lcd 29 /p0f 3 pins as lcd segment signal output pins set1_pwm0on uses p1b 1 /pwm 0 pin as pwm pin set1_pwm1on uses p1b 2 /pwm 1 pin as pwm pin set2_pwm1on_pwm0on uses p1b 1 /pwm 0 and p1b 2 /pwm 1 pins as pwm pins clr1_pwm0on uses p1b 1 /pwm 0 pin as general-purpose output port pin clr1_pwm1on uses p1b 2 /pwm 1 pin as general-purpose output port pin clr2_pwm1on_pwm0on uses p1b 1 /pwm 0 and p1b 2 /pwm 1 pins as general-purpose output port pins init_not_pwm1on_pwm0on uses p1b 1 /pwm 0 pin as pwm pin and p1b 2 /pwm 1 pin as general-purpose output port pin init_pwm1on_not_pwm0on uses p1b 1 /pwm 0 pin as general-purpose output port pin and p1b 2 /pwm 1 pin as pwm pin caution if the above macros are used, the contents of the window register are destroyed. if an embedded macro instruction is used immediately before the above macro instructions, an object error occurs when the source file is assembled and then loaded to the in-circuit emulator. to use an embedded macro instruction immediately before the above macro instructions, insert a comment statement between them. sets general-purpose output port/lcd segment signal output (p0e, p0f) sets general-purpose output port/pwm pin signal (p1b 1 , p1b 2 )
m pd17016, 17017 302 24. reserved symbol 24.1 data buffer (dbf) symbol name attribute value r/w description dbf3 mem 0.0ch r/w bits 15 through 12 of dbf dbf2 mem 0.0dh r/w bits 11 through 8 of dbf dbf1 mem 0.0eh r/w bits 7 through 4 of dbf dbf0 mem 0.0fh r/w bits 3 through 0 of dbf 24.2 system register (sysreg) symbol name attribute value r/w description ar3 mem 0.74h r bits 15 through 12 of address register note 1 ar2 mem 0.75h r bits 11 through 8 of address register note 2 ar1 mem 0.76h r/w bits 7 through 4 of address register ar0 mem 0.77h r/w bits 3 through 0 of address register wr mem 0.78h r/w window register bank mem 0.79h r/w bank register ixh mem 0.7ah r/w index register, high mph mem 0.7ah r/w memory pointer, high mpe flg 0.7ah.3 r/w memory pointer enable flag ixm mem 0.7bh r/w index register, middle mpl mem 0.7bh r/w memory pointer, low ixl mem 0.7ch r/w index register, low rph mem 0.7dh r/w general register pointer, high rpl mem 0.7eh r/w general register pointer, low psw mem 0.7fh r/w program status word bcd flg 0.7eh.0 r/w bcd operation flag cmp flg 0.7fh.3 r/w compare flag cy flg 0.7fh.2 r/w carry flag z flg 0.7fh.1 r/w zero flag ixe flg 0.7fh.0 r/w index enable flag notes 1. all the 4 bits are fixed to 0 with the m pd17016. the high-order 3 bits are fixed to 0 with the m pd17017. 2. the 4 bits are always fixed to 0 with the m pd17016.
m pd17016, 17017 303 24.3 lcd segment register symbol name attribute value r/w description lcdd0 mem 0.60h r/w lcd segment register lcdd1 mem 0.61h r/w lcd segment register lcdd2 mem 0.62h r/w lcd segment register lcdd3 mem 0.63h r/w lcd segment register lcdd4 mem 0.64h r/w lcd segment register lcdd5 mem 0.65h r/w lcd segment register lcdd6 mem 0.66h r/w lcd segment register lcdd7 mem 0.67h r/w lcd segment register lcdd8 mem 0.68h r/w lcd segment register lcdd9 mem 0.69h r/w lcd segment register lcdd10 mem 0.6ah r/w lcd segment register lcdd11 mem 0.6bh r/w lcd segment register lcdd12 mem 0.6ch r/w lcd segment register lcdd13 mem 0.6dh r/w lcd segment register lcdd14 mem 0.6eh r/w lcd segment register 24.4 port register symbol name attribute value r/w description p0a3 flg 0.70h.3 r/w bit 3 of port 0a p0a2 flg 0.70h.2 r/w bit 2 of port 0a p0a1 flg 0.70h.1 r/w bit 1 of port 0a p0a0 flg 0.70h.0 r/w bit 0 of port 0a p0b3 flg 0.71h.3 r/w bit 3 of port 0b p0b2 flg 0.71h.2 r/w bit 2 of port 0b p0b1 flg 0.71h.1 r/w bit 1 of port 0b p0b0 flg 0.71h.0 r/w bit 0 of port 0b p0c3 flg 0.72h.3 r/w bit 3 of port 0c p0c2 flg 0.72h.2 r/w bit 2 of port 0c p0c1 flg 0.72h.1 r/w bit 1 of port 0c p0c0 flg 0.72h.0 r/w bit 0 of port 0c p0d3 flg 0.73h.3 r note bit 3 of port 0d p0d2 flg 0.73h.2 r note bit 2 of port 0d p0d1 flg 0.73h.1 r note bit 1 of port 0d p0d0 flg 0.73h.0 r note bit 0 of port 0d note this port is an input port, but the assembler or in-circuit emulator does not output an error message even if an instruction that writes data to this port is described. moreover, the operation is not affected even if such a program is actually executed on the device. ------------------------------------------------------------------------------------------------------ ------------------------------------------------------------------------------------------------------ ------------------------------------------------------------------------------------------------------ ------------------------------------------------------------------------------------------------------ ------------------------------------------------------------------------------------------------------ ------------------------------------------------------------------------------------------------------ ------------------------------------------------------------------------------------------------------ ------------------------------------------------------------------------------------------------------ ------------------------------------------------------------------------------------------------------ ------------------------------------------------------------------------------------------------------ ------------------------------------------------------------------------------------------------------ ------------------------------------------------------------------------------------------------------
m pd17016, 17017 304 24.4 port register symbol name attribute value r/w description p0e3 flg 0.6bh.3 r/w bit 3 of port 0e p0e2 flg 0.6bh.2 r/w bit 2 of port 0e p0e1 flg 0.6bh.1 r/w bit 1 of port 0e p0e0 flg 0.6bh.0 r/w bit 0 of port 0e p0f3 flg 0.6dh.3 r/w bit 3 of port 0f p0f2 flg 0.6dh.2 r/w bit 2 of port 0f p0f1 flg 0.6dh.1 r/w bit 1 of port 0f p0f0 flg 0.6dh.0 r/w bit 0 of port 0f p1a3 flg 1.70h.3 r/w bit 3 of port 1a p1a2 flg 1.70h.2 r/w bit 2 of port 1a p1a1 flg 1.70h.1 r/w bit 1 of port 1a p1a0 flg 1.70h.0 r/w bit 0 of port 1a p1b3 flg 1.71h.3 r/w bit 3 of port 1b p1b2 flg 1.71h.2 r/w bit 2 of port 1b p1b1 flg 1.71h.1 r/w bit 1 of port 1b p1b0 flg 1.71h.0 r/w bit 0 of port 1b p1c3 flg 1.72h.3 r/w bit 3 of port 1c p1c2 flg 1.72h.2 r/w bit 2 of port 1c p1c1 flg 1.72h.1 r/w bit 1 of port 1c p1c0 flg 1.72h.0 r/w bit 0 of port 1c p1d3 flg 1.73h.3 r note bit 3 of port 1d p1d2 flg 1.73h.2 r note bit 2 of port 1d p1d1 flg 1.73h.1 r note bit 1 of port 1d p1d0 flg 1.73h.0 r note bit 0 of port 1d p2a0 flg 2.70h.0 r/w bit 0 of port 2a note this port is an input port, but the assembler or in-circuit emulator does not output an error message even if an instruction that writes data to this port is described. moreover, the operation is not affected even if such a program is actually executed on the device. ------------------------------------------------------------------------------------------------------ ------------------------------------------------------------------------------------------------------ ------------------------------------------------------------------------------------------------------ ------------------------------------------------------------------------------------------------------ ------------------------------------------------------------------------------------------------------ ------------------------------------------------------------------------------------------------------ ------------------------------------------------------------------------------------------------------ ------------------------------------------------------------------------------------------------------ ------------------------------------------------------------------------------------------------------ ------------------------------------------------------------------------------------------------------ ------------------------------------------------------------------------------------------------------ ------------------------------------------------------------------------------------------------------ ------------------------------------------------------------------------------------------------------ ------------------------------------------------------------------------------------------------------ ------------------------------------------------------------------------------------------------------ ------------------------------------------------------------------------------------------------------ ------------------------------------------------------------------------------------------------------ ------------------------------------------------------------------------------------------------------
m pd17016, 17017 305 24.5 register file (control register) (1/2) symbol name attribute value r/w description sp mem 0.81h r/w stack pointer sio1ts flg 0.82h.3 r/w serial interface transmit/receive start flag sio1hiz flg 0.82h.2 r/w serial interface/general-purpose port select flag sio1ck1 flg 0.82h.1 r/w serial interface i/o clock setting flag sio1ck0 flg 0.82h.0 r/w serial interface i/o clock setting flag ifcgostt flg 0.84h.0 r if counter gate status detection flag (1: open, 0: close) pllul flg 0.85h.0 r pll unlock ff flag adccmp flg 0.86h.0 r a/d converter compare result detection flag ce flg 0.87h.0 r ce pin status detection flag btm1ck1 flg 0.89h.3 r/w timer interrupt mode select flag btm1ck0 flg 0.89h.2 r/w timer interrupt mode select flag btm0ck1 flg 0.89h.1 r/w timer carry ff mode select flag btm0ck0 flg 0.89h.0 r/w timer carry ff mode select flag ksen flg 0.90h.1 r/w key source signal output start flag lcden flg 0.90h.0 r/w lcd driver display start flag ifcmd1 flg 0.92h.3 r/w if counter mode select flag (10: amif, 11: setting prohibited) ifcmd0 flg 0.92h.2 r/w if counter mode select flag (00: beep, 01: fmif) ifcck1 flg 0.92h.1 r/w if counter clock select flag ifcck0 flg 0.92h.0 r/w if counter clock select flag adcch3 flg 0.94h.3 r/w a/d converter channel select flag (dummy) adcch2 flg 0.94h.2 r/w a/d converter channel select flag adcch1 flg 0.94h.1 r/w a/d converter channel select flag adcch0 flg 0.94h.0 r/w a/d converter channel select flag keyj flg 0.96h.0 r key input judge flag btm0cy flg 0.97h.0 r timer carry ff status detection flag pllmd3 flg 0.0a1h.3 r/w pll mode select flag (dummy: 0) pllmd2 flg 0.0a1h.2 r/w pll mode select flag (dummy: 0) pllmd1 flg 0.0a1h.1 r/w pll mode select flag pllmd0 flg 0.0a1h.0 r/w pll mode select flag ifcstrt flg 0.0a3h.1 w if counter count start flag ifcres flg 0.0a3h.0 w if counter reset flag p0cgio flg 0.0a7h.0 r/w p0c input/output select flag pllrfck3 flg 0.0b1h.3 r/w pll reference frequency select flag pllrfck2 flg 0.0b1h.2 r/w pll reference frequency select flag pllrfck1 flg 0.0b1h.1 r/w pll reference frequency select flag pllrfck0 flg 0.0b1h.0 r/w pll reference frequency select flag ------------------------------------------------------------------------------------------------------ ------------------------------------------------------------------------------------------------------ ------------------------------------------------------------------------------------------------------ ------------------------------------------------------------------------------------------------------ ------------------------------------------------------------------------------------------------------ ------------------------------------------------------------------------------------------------------ ------------------------------------------------------------------------------------------------------ ------------------------------------------------------------------------------------------------------ ------------------------------------------------------------------------------------------------------ ------------------------------------------------------------------------------------------------------ ------------------------------------------------------------------------------------------------------ ------------------------------------------------------------------------------------------------------ ------------------------------------------------------------------------------------------------------ ------------------------------------------------------------------------------------------------------ ------------------------------------------------------------------------------------------------------ ------------------------------------------------------------------------------------------------------ ------------------------------------------------------------------------------------------------------ ------------------------------------------------------------------------------------------------------ ------------------------------------------------------------------------------------------------------ ------------------------------------------------------------------------------------------------------
m pd17016, 17017 306 24.5 register file (control register) (2/2) symbol name attribute value r/w description p1abio3 flg 0.0b5h.3 r/w p1a 3 input/output select flag p1abio2 flg 0.0b5h.2 r/w p1a 2 input/output select flag p1abio1 flg 0.0b5h.1 r/w p1a 1 input/output select flag p1abio0 flg 0.0b5h.0 r/w p1a 0 input/output select flag p0bbio3 flg 0.0b6h.3 r/w p0b 3 input/output select flag p0bbio2 flg 0.0b6h.2 r/w p0b 2 input/output select flag p0bbio1 flg 0.0b6h.1 r/w p0b 1 input/output select flag p0bbio0 flg 0.0b6h.0 r/w p0b 0 input/output select flag p0abio3 flg 0.0b7h.3 r/w p0a 3 input/output select flag p0abio2 flg 0.0b7h.2 r/w p0a 2 input/output select flag p0abio1 flg 0.0b7h.1 r/w p0a 1 input/output select flag p0abio0 flg 0.0b7h.0 r/w p0a 0 input/output select flag 24.6 peripheral hardware register symbol name attribute value r/w description adcr dat 02h r/w a/d converter reference voltage setting register sio1sfr dat 03h r/w serial interface presettable shift register pwmr0 dat 05h r/w pwm 0 data register pwmr1 dat 06h r/w pwm 1 data register ar dat 40h r/w address register pllr dat 41h r/w pll data register ksr dat 42h r/w key source data register ifc dat 43h r if counter data register 24.7 others symbol name attribute value description dbf dat 0fh fixed operand value of put, get, and movt instructions ix dat 01h fixed operand value of inc instruction ------------------------------------------------------------------------------------------------------ ------------------------------------------------------------------------------------------------------ ------------------------------------------------------------------------------------------------------ ------------------------------------------------------------------------------------------------------ ------------------------------------------------------------------------------------------------------ ------------------------------------------------------------------------------------------------------ ------------------------------------------------------------------------------------------------------ ------------------------------------------------------------------------------------------------------ ------------------------------------------------------------------------------------------------------
m pd17016, 17017 307 25. electrical specifications absolute maximum ratings (t a = 25 2 c) parameter symbol condition rating unit supply voltage v dd C0.3 to +6.0 v input voltage v i C0.3 to v dd + 0.3 v output voltage v o except p1b 1 through p1b 3 , p0a 2 , p0a 3 C0.3 to v dd + 0.3 v output breakdown voltage v bds1 p1b 1 -p1b 3 18.0 v v bds2 p0a 2 , p0a 3 v dd + 0.3 v high-level output current i oh 1 pin C12 ma total of all pins C20 ma low-level output current i ol 1 pin 12 ma total of all pins 20 ma operating ambient temperature t a C40 to +85 c storage temperature t stg C55 to +125 c caution if the maximum absolute rating of even one of the above parameters is exceeded even momentarily, the quality of the product may degrade. the maximum absolute ratings, therefore, specify values exceeding which the product may be physically damaged. never exceed these ratings when using the product. recommended operating conditions parameter symbol condition min. typ. max. unit supply voltage v dd1 when pll and cpu operate 4.5 5.0 5.5 v v dd2 when pll stops and cpu operates 3.5 5.0 5.5 v data retention voltage v ddr when crystal oscillation stops 2.2 5.5 v supply voltage rise time t rise v dd = 0 ? 4.5 v 500 ms input amplitude v in1 vcol, vcoh 0.5 v dd v p-p v in2 amifc, fmifc 0.5 v dd v p-p output breakdown voltage v bds p1b 1 -p1b 3 16.0 v operating ambient temperature t a C40 +85 c
m pd17016, 17017 308 dc characteristics (t a = C40 to +85 c, v dd = 4.5 to 5.5 v) parameter symbol condition min. typ. max. unit supply voltage v dd1 when cpu and pll operate 4.5 5.0 5.5 v v dd2 when cpu operates and pll stops 3.5 5.0 5.5 v supply current i dd1 when cpu and pll operate x in pin 1.2 2.4 ma sine wave input (f in = 4.5 mhz, v in = v dd ), t a = 25 c i dd2 when cpu operates and pll stops 0.45 0.90 ma halt instruction used (20 instructions executed every 1 ms) x in pin sine wave input (f in = 4.5 mhz, v in = v dd ), t a = 25 c data retention voltage v ddr1 power failure detection by timer ff. 3.5 5.5 v during crystal oscillation v ddr2 power failure detection by timer ff. 2.2 5.5 v when crystal oscillation stops v ddr3 retention of data memory (ram) 2.0 5.5 v data retention current i ddr1 when crystal oscillation stops t a = 25 c215 m a i ddr2 when crystal oscillation stops 2 10 m a v dd = 5.0 v, t a = 25 c intermediate-level output voltage v om1 com 0 , com 1 v dd = 5 v 2.3 2.5 2.7 v high-level input voltage v ih1 p0a 0 -p0a 3 , p0b 0 -p0b 3 , p0c 0 -p0c 3 , 0.8 v dd v p1a 0 -p1a 3 , p1d 0 -p1d 3 ce, int 0 v ih2 p0d 0 -p0d 3 0.6 v dd v low-level input voltage v il p0a 0 -p0a 3 , p0b 0 -p0b 3 , p0c 0 -p0c 3 , 0.2 v dd v p0d 0 -p0d 3 , p1a 0 -p1a 3 , p1d 0 -p1d 3 ce, int 0 high-level output current i oh1 p0a 0 , p0a 1 , p1a 0 -p1a 3 , p2a 0 C2.0 C10 ma v oh = v dd C 2 v, v dd = 5 v, t a = 25 c i oh2 p0b 0 -p0b 3 , p0c 0 -p0c 3 , p1b 0 , C1.0 C5.0 ma p1c 0 -p1c 3 v oh = v dd = C1 v i oh3 lcd 0 -lcd 29 , eo 0 , eo 1 v oh = v dd C 1 v C1.0 C4.0 ma low-level output current i ol1 p0a 0 -p0a 3 , p1a 0 -p1a 3 , p2a 0 5.0 15.0 ma v ol = 2 v, v dd = 5 v, t a = 25 c i ol2 p0b 0 -p0b 3 , p0c 0 -p0c 3 , p1b 0 , 1.0 7.0 ma p1c 0 -p1c 3 v ol = 1 v i ol3 ldc 0 -ldc 29 , eo 0 , eo 1 v ol = 1 v 1.0 3.5 ma i ol4 p1b 1 -p1b 3 v ol = 1 v 1.0 2.0 ma high-level input current i ih1 with vcoh pulled down v ih = v dd 0.1 0.8 ma i ih2 with vcol pulled down v ih = v dd 0.1 0.8 ma i ih3 with x in pulled down v ih = v dd 0.1 1.3 ma i ih4 with p0d 0 through p0d 3 pulled down v ih = v dd 0.05 0.13 0.30 ma output off leakage current i l1 p0a 2 , p0a 3 v oh = v dd 500 na i l2 p1b 1 -p1b 3 v oh = 16 v 500 na i l3 eo 0 , eo 1 v oh = v dd , v ol = 0 v 100 na
m pd17016, 17017 309 ac characteristics (t a = C40 to +85 c, v dd = 4.5 to 5.5 v) parameter symbol condition min. typ. max. unit operating frequency f in1 vcol mf mode, sine wave input v in = 0.2 v p-p 0.5 30 mhz f in2 vcol hf mode, sine wave input v in = 0.2 v p-p 5 40 mhz f in3 vcoh sine wave input v in = 0.2 v p-p 9 150 mhz f in4 amifc sine wave input v in = 0.3 v p-p 0.1 1 mhz f in5 amifc sine wave input v in = 0.05 v p-p 0.44 0.46 mhz f in6 fmifc sine wave input v in = 0.3 v p-p 5 15 mhz f in7 fmifc sine wave input v in = 0.06 v p-p 10.5 10.9 mhz ad conversion resolution 6 bit ad conversion total error t a = C10 to +50 c 1 1.5 lsb reference characteristics parameter symbol condition min. typ. max. unit supply current i dd3 when cpu and pll operate 15 ma vcoh sine wave input f in = 150 mhz, v in = 0.3 v p-p v dd = 5 v, t a = 25 c high-level output current i oh3 com 0 , com 1 v oh = v dd C 1 v C0.2 ma intermediate-level i om1 com 0 , com 1 v om = v dd C 1 v C20 m a output current i om2 com 0 , com 1 v om = 1 v 20 m a low-level output current i ol5 com 0 , com 1 v ol = 1 v 0.2 ma
m pd17016, 17017 310 26. package package of mass-produced model caution the es model differs from the mass-produced model in package and materials. refer to the package drawing of the es model. item millimeters inches g q f 1.8 0.125?.075 1.0 s 0.031 0.005?.003 0.039 s80gf-80-3b9-3 note each lead centerline is located within 0.15 mm (0.006 inch) of its true position (t.p.) at maximum material condition. 3.0 max. 0.119 max. d 17.2?.2 0.677?.008 r5 ? 5 ? b 20.0?.2 0.787 +0.009 ?.008 a 23.2?.2 0.913 +0.009 ?.008 80 pin plastic qfp (14 20) c 14.0?.2 0.551 +0.009 ?.008 j 0.8 (t.p.) 0.031 (t.p.) i 0.15 0.006 h 0.35?.10 0.014 +0.004 ?.005 p 2.7 0.106 n 0.10 0.004 l 0.8?.2 0.031 +0.009 ?.008 m 0.15 0.006 +0.004 ?.003 k 1.6?.2 0.063?.008 +0.10 ?.05 detail of lead end m 64 65 40 80 1 25 24 41 a b c d f g h i j k m l n p s q r
m pd17016, 17017 311 package of es model es 80-pin ceramic qfp (reference) (unit: mm) 64 1 41 24 12.0 14.2 20.0 18.4 0.8 0.32 0.15 2.25 bottom surface cautions 1. the leads are diagonally molded on the bottom surface. 2. because cutting of the tip of the lead is not subject to quality control, the lead length is not specified.
m pd17016, 17017 312 27. recommended soldering conditions solder the m pd17016 and 17017 under the following recommended conditions. for details of the recommended soldering conditions, refer to information document semiconductor device mounting technology manual (c10535e) . for the soldering methods and conditions other than those recommended, consult nec. table 27-1. soldering conditions of surface mount type m pd17016gf-xxx-3b9: 80-pin plastic qfp (14 20 mm) m pd17017gf-xxx-3b9: 80-pin plastic qfp (14 20 mm) soldering method soldering condition symbol of recommended soldering condition infrared reflow package peak temperature: 235 c, time: 30 seconds max. (210 c min.), ir35-207-2 number of times: 2 max., number of days: 7 note (after this, prebaking at 125 c for 20 hours is necessary.) products other than those supplied in heat-resistance tray (magazine, taping, and heat-labile tray) cannot be baked in their packs. vps package peak temperature: 215 c, time: 40 seconds max. (200 c min.), vp15-207-2 number of times: 2 max., number of days: 7 note (after this, prebaking at 125 c for 20 hours is necessary.) products other than those supplied in heat-resistance tray (magazine, taping, and heat-labile tray) cannot be baked in their packs. wave soldering solder bath temperature: 260 c max., time: 10 seconds max., ws60-207-1 number of times: 1, preheating temperature: 120 c max. (package surface temperature), number of days: 7 note (after this, prebaking at 125 c for 20 hours is necessary.) partial heating pin temperature: 300 c max., time: 3 seconds max. (per side of device) C note the number of days for which the device can be left at 25 c, 65 % rh max. after the dry pack has been opened. caution do not use two or more soldering methods in combination (except the partial heating method).
m pd17016, 17017 313 appendix a. note on connecting crystal resonator when using the system clock oscillation circuit, the following points must be noted in wiring the portion indicated by the dotted line in the figure below to prevent adverse influence from wiring capacitance. ? keep the wiring length as short as possible. ? if capacitances c1 and c2 are too high, the oscillation start characteristic may be degraded or the current consumption may increase. ? generally, connect the trimmer capacitor for adjusting the oscillation frequency to the x in pin. depending on the crystal resonator used, however, the oscillation stabilization differs. therefore, evaluate the crystal resonator actually to be used. ? the crystal frequency cannot be accurately adjusted because of probe capacitance if an emulation probe is connected to the x out or x in pin. adjust the frequency while measuring the lcd drive waveform (125 hz) or vco oscillation frequency. x out x in 4.5-mhz crystal resonator c1 c2 pd17016 pd17017 m m
m pd17016, 17017 314 appendix b. differences among m pd17016, 17017, 17003a, 17005, and 17010 (1) hardware item m pd17010 m pd17003a m pd17005 rom 16 kb 8 kb 16 kb (7932 16 bits) (3836 16 bits) (7932 16 bits) ram 432 4 bits 320 4 bits 432 4 bits output port 13 pins (+30: lcd segment pins) 9 pins (+30: lcd segment pins) control register 41 4 bits 33 4 bits general register pointer 5 bits 4 bits stack level 9 levels 7 levels serial interface 2 modes (3 channels): serial i/o mode, i 2 c bus mode ? sio0 clock ? sio1 clock 37.5, 75, 112.5, 225 khz 75, 150, 225, 450 khz ? sio1 clock ? sio2 clock external, 37.5, 75, 450 khz external, 75, 150, 450 khz ? hysteresis characteristics for scl, sda, sck 0 , sck 1 , si 0 , and si 1 pins d/a converter frequency 4394.5 hz 878.9 hz d/a converter output (pwm) 3 channels interrupt ? 6 sources ? 5 sources external: 1 source (int 0 pin) external: 2 sources (int 0 and int 1 pins) internal : 4 sources (tm, btm1, sio0, ifc) internal : 3 sources (tm, sio1, ifc) external/internal: 1 source (int 1 pin or overflow of timer/counter) ? interrupt priority (vector address) ? interrupt priority (vector address) 1. (6h) int 0 pin 1. (5h) int 0 pin 2. (5h) int 1 pin 2. (4h) int 1 pin (shared with overflow of timer/counter) 3. (3h) timer 3. (4h) 12-bit timer 4. (2h) serial interface 1 4. (3h) basic timer 1 5. (1h) frequency counter 5. (2h) serial interface 0 6. (1h) frequency counter ? automatic saving of system register (3 levels) ? automatic saving of system register (4 levels) (wr, bank, rp, psword) (bank, ixe) ? address change of irqxxx flag timer ? basic timer 0 carry ? timer carry (1, 5, 100, 250 ms) (1, 5, 100, 250 ms) ? basic timer 1 interrupt ? timer interrupt (1, 5, 100, 250 ms) (1, 5, 100, 250 ms) ? 12-bit timer (10 m s to 4095 ms) frequency counter frequency measurement (if measurement) and external gate width measurement functions selectable clock generator port (cgp) ? cgp output: 1 line ? sg (signal generator) function ? vdp (variable duty pulse) function pll frequency synthesizer provided phase comparator (unlock detection by program. unlock ff delay time selectable) operational amplifier for none provided pll frequency synthesizer lowpass filter package 80-pin plastic qfp (14 20 mm)
m pd17016, 17017 315 m pd17016 m pd17017 8 kb 16 kb (3836 16 bits) (7932 16 bits) 320 4 bits 432 4 bits 9 pins (+8: lcd segment pins) 19 4 bits 4 bits 7 levels 1 channel: serial i/o mode ? sio1 clock external, 75, 150, 450 khz 878.9 hz 2 channels ? 2 sources external: 1 source (int 0 pin) internal : 1 source (timer) ? interrupt priority (vector address) 1. (5h) int 0 pin 2. (3h) timer ? automatic saving of system register (4 levels) (bank, ixe) ? timer carry (1, 5, 100, 250 ms) ? timer interrupt (1, 5, 100, 250 ms) frequency measurement function only none (beep output provided) internal (without unlock ff delay time select function) none 80-pin plastic qfp (14 20 mm)
m pd17016, 17017 316 (2) software item m pd17010 m pd17003a m pd17005 m pd17016 m pd17017 setting of lcd segment write (poke) instruction and flag manipulation manipulated by software macro output or output port of embedded macroinstructions can be used. supplied with device file. lcd 22 /p0e 0 through lcd 29 /p0f 3 pins setting of output port or pwm output of p1b 1 /pwm 0 and p1b 2 /pwm 1 pin interrupt request lag write (poke) if write (poke) instruction is used, instruction and error occurs during assembly. flag manipulation if flag manipulation embedded embedded macroinstruction is used, error macroinstructions occurs during assembly. can be used. subjected flags ? irqifc ? irqsio1 ? irqtm ? irq1 ? irq0 to write above flags, use macro library irq.mac. enabling interrupt write (poke) instruction and flag manipulation embedded macroinstructions can be used. level judge of int 0 pin write (poke) instruction and embedded macroinstructions sktn and skfn can be used. if counter control register read (peek) if read (peek) instruction is used, error occurs during assembly. therefore, instruction is used. macroinstructions that creates peek instruction to object when they are at this time, 0 expanded to setn instruction must not be used. is always read. subjected flags setn instruction ? ifcres can be also used. ? ifcstrt to read above flags, use macro library ifcset.lib. beep output setting none manipulated by software macro supplied with device file. (3) development tools item m pd17010 m pd17003a m pd17005 m pd17016 m pd17017 hardware se board se-17010 emulation probe ep-17003gf software device file as17010 as17003 as17005 as17016 macro library none ? ifcset.lib ? ifcset.lib ? ifcset.lib ? irq.mac ? d17016.inc ? d17017.inc one-time prom m pd17p010 m pd17p005
m pd17016, 17017 317 (4) notes on reserved word names the reserved words of the control registers of the m pd17016 and 17017 are different from some reserved words of the m pd17003a and 17005. the following table shows the differences in the reserved words between the m pd17016/17017 and m pd17003a/17005. note that this table shows only the different reserved words. item m pd17003a m pd17005 m pd17016 m pd17017 timer tmmd3 btm1ck1 tmmd2 btm1ck0 tmmd1 btm0ck1 tmmd0 btm0ck0 tmcy btm0cy pll frequency synthesizer pluldly3 none pluldly2 pluldly1 pluldly0 pllrfmd3 pllrfck3 pllrfmd2 pllrfck2 pllrfmd1 pllrfck1 pllrfmd0 pllrfck0 d/a converter pwm2on none pwm1on note pwm0on note cgpon lcd controller/driver p0yon none p0xon p0eon note p0fon note frequency counter ifcg ifcgostt serial interface sio2ts sio1ts sio2hiz sio1hiz sio2ck1 sio1ck1 sio2ck0 sio1ck0 sio1ch none sb sio1ms sio1tx sback note these reserved words are manipulated by software macros with the m pd17016 and 17017.
m pd17016, 17017 318 item m pd17003a m pd17005 m pd17016 m pd17017 serial interface sio1nwt none sio1wrq1 sio1wrq0 sio1sf8 sio1sf9 sbbsy sbstt sio1imd3 sio1imd2 sio1imd1 sio1imd0 sio1ck3 sio1ck2 sio1ck1 sio1ck0 interrupt int1 none int0 note ieg1 ieg0 ipifc ipsio1 iptm note ip1 ip0 irqifc irqsio1 irqtm note irq1 irq0 note note these reserved words are manipulated by software macros with the m pd17016 and 17017.
m pd17016, 17017 319 appendix c. development tools the following development tools are available to support development of the program of the m pd17016 and 17017. hardware name description in-circuit emulator ie-17k, ie-17k-et, and emu-17k are in-circuit emulators that can be commonly used with any model ie-17k, in 17k series. ie-17k and ie-17k-et are connected to host machine, which is pc-9800 series or ie-17k-et note 1 , ibm pc/at tm , with rs-232-c. emu-17k is mounted to expansion slot of pc-9800 series. emu-17k note 2 when these in-circuit emulators are used in combination with system evaluation board (se board) dedicated to each model, they operate as emulators corresponding to that model. when man-machine interface software simplehost ? is used, a more sophisticated debugging environment can be created. emu-17k has a function for checking the contents of data memory real-time. se board se-17010 is se board for m pd17016 and 17017. this se board alone can be used to evaluate system (se-17010) or in combination with in-circuit emulator for debugging. emulation probe ep-17003gf is emulation probe for m pd17016gf and 17017gf. it connects se board and target (ep-17003gf) system when used with ev-9200g-80 note 3 . conversion socket ev-9200g-80 is conversion socket for 80-pin plastic qfp (14 20 mm) and is used to connect ep- (ev-9200g-80 note 3 ) 17003gf and target system. prom programmer af-9703, af-9704, af-9705, and af-9706 are prom programmers corresponding to m pd17p005. af-9703 note 4 , they can program the m pd17p005 when connected to program adapter af-9803. af-9704 note 4 , af-9705 note 4 , af-9706 note 4 program adapter af-9803 is adapter for programming m pd17p005, and is used in combination with af-9703, af-9704, (af-9803 note 4 ) af-9705, or af-9706. notes 1. low-cost model: external power supply type 2. this is a product by i.c corp. for details, consult i.c corp. (tokyo, 03-3447-3793) 3 . one ev-9200g-80 is provided with the ep-17003gf. five ev-9200g-80s are also available as a set. 4. these are products of ando electric co., ltd. for details, consult ando electric co, ltd. (tokyo, 03- 3733-1163).
m pd17016, 17017 320 software name description host machine os supply order code media pc-9800 series ms-dos tm 5"2hd m s5a10as17k 3.5"2hd m s5a13as17k ibm pc/at pc dos tm 5"2hc m s7b10as17k 3.5"2hc m s7b13as17k pc-9800 series ms-dos 5"2hd m s5a10as17016 3.5"2hc m s5a13as17016 ibm pc/at pc dos 5"2hc m s7b10as17016 3.5"2hc m s7b13as17016 pc-9800 series ms-dos windows 5"2hd m s5a10ie17k 3.5"2hd m s5a13ie17k ibm pc/at pc dos 5"2hc m s7b10ie17k 3.5"2hc m s7b13ie17k remark the following versions of oss are supported. os version ms-dos ver.3.30 to ver.5.00a note pc dos ver.3.1 to ver.5.0 note windows ver.3.0 to ver.3.1 note ms-dos ver.5.00/5.00a and pc dos ver.5.0 have a task swap function, but this function cannot be used with this software. as17k is an assembler that can be commonly used with any model of 17k series. to develop program of m pd17016 and 17017, this as17k is used in combination with device file (as17016). as17016 contains device file for m pd17016 and 17017. it is used in combination with 17k series assembler (as17k). simplehost is software that serves as man-machine interface on windows tm when program is developed by using in-circuit emulator and personal computer. 17k series assembler (as17k) device file (as17016) support software ( simplehost )
m pd17016, 17017 321 [memo]
m pd17016, 17017 322 notes for cmos devices 1 precaution against esd for semiconductors note: strong electric field, when exposed to a mos device, can cause destruction of the gate oxide and ultimately degrade the device operation. steps must be taken to stop generation of static electricity as much as possible, and quickly dissipate it once, when it has occurred. environmental control must be adequate. when it is dry, humidifier should be used. it is recommended to avoid using insulators that easily build static electricity. semiconductor devices must be stored and transported in an anti-static container, static shielding bag or conductive material. all test and measurement tools including work bench and floor should be grounded. the operator should be grounded using wrist strap. semiconductor devices must not be touched with bare hands. similar precautions need to be taken for pw boards with semiconductor devices on it. 2 handling of unused input pins for cmos note: no connection for cmos device inputs can be cause of malfunction. if no connection is provided to the input pins, it is possible that an internal input level may be generated due to noise, etc., hence causing malfunction. cmos device behave differently than bipolar or nmos devices. input levels of cmos devices must be fixed high or low by using a pull-up or pull-down circuitry. each unused pin should be connected to v dd or gnd with a resistor, if it is considered to have a possibility of being an output pin. all handling related to the unused pins must be judged device by device and related specifications governing the devices. 3 status before initialization of mos devices note: power-on does not necessarily define initial status of mos device. produc- tion process of mos does not define the initial operation status of the device. immediately after the power source is turned on, the devices with reset function have not yet been initialized. hence, power-on does not guarantee out-pin levels, i/o settings or contents of registers. device is not initialized until the reset signal is received. reset operation must be executed imme- diately after power-on for devices having reset function.
m pd17016, 17017 323 nec electronics inc. (u.s.) mountain view, california tel: 800-366-9782 fax: 800-729-9288 nec electronics (germany) gmbh duesseldorf, germany tel: 0211-65 03 02 fax: 0211-65 03 490 nec electronics (uk) ltd. milton keynes, uk tel: 01908-691-133 fax: 01908-670-290 nec electronics italiana s.r.1. milano, italy tel: 02-66 75 41 fax: 02-66 75 42 99 nec electronics hong kong ltd. hong kong tel: 2886-9318 fax: 2886-9022/9044 nec electronics hong kong ltd. seoul branch seoul, korea tel: 02-528-0303 fax: 02-528-4411 nec electronics singapore pte. ltd. united square, singapore 1130 tel: 253-8311 fax: 250-3583 nec electronics taiwan ltd. taipei, taiwan tel: 02-719-2377 fax: 02-719-5951 nec do brasil s.a. sao paulo-sp, brasil tel: 011-889-1680 fax: 011-889-1689 nec electronics (germany) gmbh benelux office eindhoven, the netherlands tel: 040-2445845 fax: 040-2444580 nec electronics (france) s.a. france tel: 01-30-67 58 00 fax: 01-30-67 58 99 nec electronics (france) s.a. spain office madrid, spain tel: 01-504-2787 fax: 01-504-2860 nec electronics (germany) gmbh scandinavia office taeby sweden tel: 8-63 80 820 fax: 8-63 80 388 regional information some information contained in this document may vary from country to country. before using any nec product in your application, please contact the nec office in your country to obtain a list of authorized representatives and distributors. they will verify: ? device availability ? ordering information ? product release schedule ? availability of related technical literature ? development environment specifications (for example, specifications for third-party tools and components, host computers, power plugs, ac supply voltages, and so forth) ? network requirements in addition, trademarks, registered trademarks, export restrictions, and other legal issues may also vary from country to country. j96. 3
m pd17016, 17017 324 the export of this product from japan is regulated by the japanese government. to export this product may be prohibited without governmental license, the need for which must be judged by the customer. the export or re-export of this product from a country other than japan may also be prohibited without a license from that country. please call an nec sales representative. simplehost is a registered trademark of nec corporation. ms-dos and windows are trademarks of microsoft corporation. pc/at and pc dos are trademarks of ibm corporation. no part of this document may be copied or reproduced in any form or by any means without the prior written consent of nec corporation. nec corporation assumes no responsibility for any errors which may appear in this document. nec corporation does not assume any liability for infringement of patents, copyrights or other intellectual property rights of third parties by or arising from use of a device described herein or any other liability arising from use of such device. no license, either express, implied or otherwise, is granted under any patents, copyrights or other intellectual property rights of nec corporation or others. while nec corporation has been making continuous effort to enhance the reliability of its semiconductor devices, the possibility of defects cannot be eliminated entirely. to minimize risks of damage or injury to persons or property arising from a defect in an nec semiconductor device, customers must incorporate sufficient safety measures in its design, such as redundancy, fire-containment, and anti-failure features. nec devices are classified into the following three quality grades: "standard", "special", and "specific". the specific quality grade applies only to devices developed based on a customer designated "quality assurance program" for a specific application. the recommended applications of a device depend on its quality grade, as indicated below. customers must check the quality grade of each device before using it in a particular application. standard: computers, office equipment, communications equipment, test and measurement equipment, audio and visual equipment, home electronic appliances, machine tools, personal electronic equipment and industrial robots special: transportation equipment (automobiles, trains, ships, etc.), traffic control systems, anti-disaster systems, anti-crime systems, safety equipment and medical equipment (not specifically designed for life support) specific: aircrafts, aerospace equipment, submersible repeaters, nuclear reactor control systems, life support systems or medical equipment for life support, etc. the quality grade of nec devices is "standard" unless otherwise specified in nec's data sheets or data books. if customers intend to use nec devices for applications other than those specified for standard quality grade, they should contact an nec sales representative in advance. anti-radioactive design is not implemented in this product. m4 96.5


▲Up To Search▲   

 
Price & Availability of UPD17016GF-XXX-3B9

All Rights Reserved © IC-ON-LINE 2003 - 2022  

[Add Bookmark] [Contact Us] [Link exchange] [Privacy policy]
Mirror Sites :  [www.datasheet.hk]   [www.maxim4u.com]  [www.ic-on-line.cn] [www.ic-on-line.com] [www.ic-on-line.net] [www.alldatasheet.com.cn] [www.gdcy.com]  [www.gdcy.net]


 . . . . .
  We use cookies to deliver the best possible web experience and assist with our advertising efforts. By continuing to use this site, you consent to the use of cookies. For more information on cookies, please take a look at our Privacy Policy. X